moving: don't slither and slide over tabs when they are overlong

This fixes https://savannah.gnu.org/bugs/?52183.

Tested-by: David Lawrence Ramsey <pooka109@gmail.com>
Improved-by: David Lawrence Ramsey <pooka109@gmail.com>
master
Benno Schulenberg 2017-10-20 20:00:12 +02:00
parent 2356693b81
commit 3018ab4706
1 changed files with 7 additions and 8 deletions

View File

@ -80,11 +80,12 @@ size_t proper_x(filestruct *line, size_t *leftedge, bool forward,
column / tabsize < (*leftedge + editwincols - 1) / tabsize))) { column / tabsize < (*leftedge + editwincols - 1) / tabsize))) {
index++; index++;
*leftedge = leftedge_for(strnlenpt(line->data, index), line);
if (shifted != NULL) if (shifted != NULL)
*shifted = TRUE; *shifted = TRUE;
} }
if (ISSET(SOFTWRAP))
*leftedge = leftedge_for(strnlenpt(line->data, index), line);
#endif #endif
return index; return index;
@ -95,17 +96,15 @@ size_t proper_x(filestruct *line, size_t *leftedge, bool forward,
void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward) void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
{ {
bool shifted = FALSE; bool shifted = FALSE;
size_t was_edge = *leftedge;
openfile->current_x = proper_x(openfile->current, leftedge, forward, openfile->current_x = proper_x(openfile->current, leftedge, forward,
actual_last_column(*leftedge, target), &shifted); actual_last_column(*leftedge, target), &shifted);
/* If the index was incremented, try going to the target column. */ /* If the index was incremented, try going to the target column. */
if (shifted) { if (shifted || *leftedge < was_edge)
size_t newer_x = actual_x(openfile->current->data, *leftedge + target); openfile->current_x = proper_x(openfile->current, leftedge, forward,
actual_last_column(*leftedge, target), &shifted);
if (newer_x > openfile->current_x)
openfile->current_x = newer_x;
}
openfile->placewewant = *leftedge + target; openfile->placewewant = *leftedge + target;
} }