* src/files.c (update_poshistory): Do not add directories to the
list of file positions. This fixes Savannah bug #46971.
* src/*.c: Adjust some indentation and some line wrapping.
+ * src/prompt.c (do_statusbar_prev_word): When in the middle of a
+ word, jump to the start of the current word, not to the start of
+ the preceding one. This fixes Savannah bug #46970.
2016-01-25 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (update_poshistory): Handle an update of the first
/* Move to the previous word in the prompt text. */
void do_statusbar_prev_word(void)
{
- char *char_mb;
- int char_mb_len;
- bool begin_line = FALSE;
+ bool seen_a_word = FALSE, step_forward = FALSE;
assert(answer != NULL);
- char_mb = charalloc(mb_cur_max());
-
- /* Move backward until we find the character before the first letter
- * of the current word. */
- while (!begin_line) {
- char_mb_len = parse_mbchar(answer + statusbar_x, char_mb, NULL);
-
- /* If we've found it, stop moving backward through the current
- * line. */
- if (!is_word_mbchar(char_mb, FALSE))
- break;
-
- if (statusbar_x == 0)
- begin_line = TRUE;
- else
- statusbar_x = move_mbleft(answer, statusbar_x);
- }
-
- /* Move backward until we find the last letter of the previous
- * word. */
- if (statusbar_x == 0)
- begin_line = TRUE;
- else
+ /* Move backward until we pass over the start of a word. */
+ while (statusbar_x != 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
- while (!begin_line) {
- char_mb_len = parse_mbchar(answer + statusbar_x, char_mb, NULL);
-
- /* If we've found it, stop moving backward through the current
- * line. */
- if (is_word_mbchar(char_mb, FALSE))
+ if (is_word_mbchar(answer + statusbar_x, FALSE))
+ seen_a_word = TRUE;
+ else if (seen_a_word) {
+ /* This is space now: we've overshot the start of the word. */
+ step_forward = TRUE;
break;
-
- if (statusbar_x == 0)
- begin_line = TRUE;
- else
- statusbar_x = move_mbleft(answer, statusbar_x);
- }
-
- /* If we've found it, move backward until we find the character
- * before the first letter of the previous word. */
- if (!begin_line) {
- if (statusbar_x == 0)
- begin_line = TRUE;
- else
- statusbar_x = move_mbleft(answer, statusbar_x);
-
- while (!begin_line) {
- char_mb_len = parse_mbchar(answer + statusbar_x, char_mb,
- NULL);
-
- /* If we've found it, stop moving backward through the
- * current line. */
- if (!is_word_mbchar(char_mb, FALSE))
- break;
-
- if (statusbar_x == 0)
- begin_line = TRUE;
- else
- statusbar_x = move_mbleft(answer, statusbar_x);
}
-
- /* If we've found it, move forward to the first letter of the
- * previous word. */
- if (!begin_line)
- statusbar_x += char_mb_len;
}
- free(char_mb);
+ if (step_forward)
+ /* Move one character forward again to sit on the start of the word. */
+ statusbar_x = move_mbright(answer, statusbar_x);
update_the_bar();
}