Commit 9f2c80db authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

moving: when determining where we are on the screen, use placewewant

To make dynamic Home and End work properly when double-width characters
straddle a chunk boundary, use the spot where the cursor is really shown
instead of the "actual x" position of the current character, because the
latter might be on the preceding row.

This fixes https://savannah.gnu.org/bugs/?50737.
No related merge requests found
Showing with 6 additions and 4 deletions
+6 -4
......@@ -350,7 +350,7 @@ void do_next_word_void(void)
void do_home(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t was_column = openfile->placewewant;
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
bool moved = FALSE;
......@@ -380,17 +380,19 @@ void do_home(bool be_clever)
if (!moved && ISSET(SOFTWRAP)) {
/* If already at the left edge of the screen, move fully home.
* Otherwise, move to the left edge. */
if (openfile->current_x == leftedge_x && be_clever)
if (was_column % editwincols == 0 && be_clever)
openfile->current_x = 0;
else {
openfile->current_x = leftedge_x;
openfile->placewewant = (was_column / editwincols) * editwincols;
moved_off_chunk = FALSE;
}
} else if (!moved)
#endif
openfile->current_x = 0;
openfile->placewewant = xplustabs();
if (moved_off_chunk)
openfile->placewewant = 0;
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
......@@ -413,7 +415,7 @@ void do_home_void(void)
void do_end(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = xplustabs();
size_t was_column = openfile->placewewant;
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment