moving: limit the target column when it is beyond the last chunk

When the column given in gotoline() is beyond the last available
column in the row of the last chunk, then set placewewant to the
actual end of the chunk, to prevent surprising jumps to the left
when moving up or down from there.

This fixes https://savannah.gnu.org/bugs/?50995.
master
Benno Schulenberg 2017-05-11 10:52:39 +02:00
parent 6971db773b
commit 08fd5b349b
1 changed files with 6 additions and 0 deletions

View File

@ -883,6 +883,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
openfile->current_x = actual_x(openfile->current->data, column - 1);
openfile->placewewant = column - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
strlenpt(openfile->current->data) / editwincols)
openfile->placewewant = strlenpt(openfile->current->data);
#endif
/* When the position was manually given, center the target line. */
if (interactive) {
adjust_viewport(CENTERING);