mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 14:51:36 +03:00
softwrap: count softwrapped chunks properly in do_gotolinecolumn()
Use go_forward_chunks() to count softwrapped chunks between the current cursor position and the bottom of the file. Now softwrap mode and non-softwrap mode behave the same way when moving to a line and column non-interactively, instead of the former's always centering the screen.
This commit is contained in:
parent
456d66b904
commit
1570651e30
24
src/search.c
24
src/search.c
@ -883,17 +883,29 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
openfile->placewewant = column - 1;
|
||||
|
||||
/* When the position was manually given, center the target line. */
|
||||
if (interactive || ISSET(SOFTWRAP)) {
|
||||
if (interactive) {
|
||||
adjust_viewport(CENTERING);
|
||||
refresh_needed = TRUE;
|
||||
} else {
|
||||
int rows_from_tail;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *line = openfile->current;
|
||||
size_t leftedge = (xplustabs() / editwincols) * editwincols;
|
||||
|
||||
rows_from_tail = (editwinrows / 2) -
|
||||
go_forward_chunks(editwinrows / 2, &line, &leftedge);
|
||||
} else
|
||||
#endif
|
||||
rows_from_tail = openfile->filebot->lineno -
|
||||
openfile->current->lineno;
|
||||
|
||||
/* If the target line is close to the tail of the file, put the last
|
||||
* line of the file on the bottom line of the screen; otherwise, just
|
||||
* line or chunk on the bottom line of the screen; otherwise, just
|
||||
* center the target line. */
|
||||
if (openfile->filebot->lineno - openfile->current->lineno <
|
||||
editwinrows / 2) {
|
||||
openfile->current_y = editwinrows - openfile->filebot->lineno +
|
||||
openfile->current->lineno - 1;
|
||||
if (rows_from_tail < editwinrows / 2) {
|
||||
openfile->current_y = editwinrows - 1 - rows_from_tail;
|
||||
adjust_viewport(STATIONARY);
|
||||
} else
|
||||
adjust_viewport(CENTERING);
|
||||
|
Loading…
Reference in New Issue
Block a user