diff --git a/src/move.c b/src/move.c index 7529568023bd6a464e7bcf5eb2985dc4aad6f325..104165ab071c4176d9f00062349004749e1baeaa 100644 --- a/src/move.c +++ b/src/move.c @@ -146,7 +146,6 @@ void do_page_down(void) void do_para_begin(bool allow_update) { filestruct *current_save = openfile->current; - const size_t pww_save = openfile->placewewant; if (openfile->current != openfile->fileage) { do { @@ -156,10 +155,9 @@ void do_para_begin(bool allow_update) } openfile->current_x = 0; - openfile->placewewant = 0; if (allow_update) - edit_redraw(current_save, pww_save); + edit_redraw(current_save); } /* Move up to the beginning of the last beginning-of-paragraph line @@ -178,7 +176,6 @@ void do_para_begin_void(void) void do_para_end(bool allow_update) { filestruct *const current_save = openfile->current; - const size_t pww_save = openfile->placewewant; while (openfile->current != openfile->filebot && !inpar(openfile->current)) @@ -194,14 +191,11 @@ void do_para_end(bool allow_update) if (openfile->current != openfile->filebot) { openfile->current = openfile->current->next; openfile->current_x = 0; - openfile->placewewant = 0; - } else { + } else openfile->current_x = strlen(openfile->current->data); - openfile->placewewant = xplustabs(); - } if (allow_update) - edit_redraw(current_save, pww_save); + edit_redraw(current_save); } /* Move down to the beginning of the last line of the current paragraph. @@ -219,7 +213,6 @@ void do_para_end_void(void) * screen afterwards. */ void do_prev_word(bool allow_punct, bool allow_update) { - size_t pww_save = openfile->placewewant; filestruct *current_save = openfile->current; bool seen_a_word = FALSE, step_forward = FALSE; @@ -256,11 +249,10 @@ void do_prev_word(bool allow_punct, bool allow_update) /* Move one character forward again to sit on the start of the word. */ openfile->current_x = move_mbright(openfile->current->data, openfile->current_x); - openfile->placewewant = xplustabs(); /* If allow_update is TRUE, update the screen. */ if (allow_update) - edit_redraw(current_save, pww_save); + edit_redraw(current_save); } /* Move to the previous word in the file, treating punctuation as part of a @@ -276,7 +268,6 @@ void do_prev_word_void(void) * otherwise. */ bool do_next_word(bool allow_punct, bool allow_update) { - size_t pww_save = openfile->placewewant; filestruct *current_save = openfile->current; bool started_on_word = is_word_mbchar(openfile->current->data + openfile->current_x, allow_punct); @@ -309,11 +300,9 @@ bool do_next_word(bool allow_punct, bool allow_update) break; } - openfile->placewewant = xplustabs(); - /* If allow_update is TRUE, update the screen. */ if (allow_update) - edit_redraw(current_save, pww_save); + edit_redraw(current_save); /* Return whether we started on a word. */ return started_on_word; diff --git a/src/nano.c b/src/nano.c index 1658b3c69e4d8c1acfd1c4e592ced35a9ab3e91d..ec30a8ae17d94bc0b5e97b55eb4340e06ee04107 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1746,7 +1746,6 @@ int do_mouse(void) #ifndef NANO_TINY size_t current_x_save = openfile->current_x; #endif - size_t pww_save = openfile->placewewant; sameline = (mouse_y == openfile->current_y); @@ -1798,8 +1797,6 @@ int do_mouse(void) get_page_start(xplustabs()) + mouse_x); } - openfile->placewewant = xplustabs(); - #ifndef NANO_TINY /* Clicking where the cursor is toggles the mark, as does * clicking beyond the line length with the cursor at the end of @@ -1811,7 +1808,7 @@ int do_mouse(void) /* The cursor moved; clean the cutbuffer on the next cut. */ cutbuffer_reset(); - edit_redraw(current_save, pww_save); + edit_redraw(current_save); } /* No more handling is needed. */ diff --git a/src/proto.h b/src/proto.h index dfe46ea9c984fbbbdef386d06ebcfec27da324dd..6a354f2fdc45e28344f7c6ed0b5f837e6d214dd2 100644 --- a/src/proto.h +++ b/src/proto.h @@ -792,7 +792,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int int update_line(filestruct *fileptr, size_t index); bool need_screen_update(size_t pww_save); void edit_scroll(scroll_dir direction, ssize_t nlines); -void edit_redraw(filestruct *old_current, size_t pww_save); +void edit_redraw(filestruct *old_current); void edit_refresh(void); void edit_update(update_type location); void total_redraw(void); diff --git a/src/search.c b/src/search.c index 13d426b8b0d2644aa18abbeee26fa1b2a3ccf2e3..cb46e679b6c3bd0437b90b2b6c59548898088fcd 100644 --- a/src/search.c +++ b/src/search.c @@ -482,7 +482,6 @@ void go_looking(void) { filestruct *was_current = openfile->current; size_t was_current_x = openfile->current_x; - size_t was_pww = openfile->placewewant; int didfind; findnextstr_wrap_reset(); @@ -498,8 +497,7 @@ void go_looking(void) openfile->current_x == was_current_x) statusbar(_("This is the only occurrence")); - openfile->placewewant = xplustabs(); - edit_redraw(was_current, was_pww); + edit_redraw(was_current); search_replace_abort(); } @@ -1113,9 +1111,7 @@ void do_find_bracket(void) /* If count is zero, we've found a matching bracket. Update * the screen and get out. */ if (count == 0) { - size_t pww_save = openfile->placewewant; - openfile->placewewant = xplustabs(); - edit_redraw(current_save, pww_save); + edit_redraw(current_save); break; } } else { diff --git a/src/text.c b/src/text.c index 17794cc16b8a6bfc655fc7ad575231f94e631cd9..8106a5dc55f3135fdf80463cc7ee1ffe0efecdda 100644 --- a/src/text.c +++ b/src/text.c @@ -1950,7 +1950,6 @@ void do_justify(bool full_justify) filestruct *edittop_save = openfile->edittop; filestruct *current_save = openfile->current; size_t current_x_save = openfile->current_x; - size_t pww_save = openfile->placewewant; size_t totsize_save = openfile->totsize; #ifndef NANO_TINY filestruct *mark_begin_save = openfile->mark_begin; @@ -2295,7 +2294,6 @@ void do_justify(bool full_justify) openfile->edittop = edittop_save; openfile->current = current_save; openfile->current_x = current_x_save; - openfile->placewewant = pww_save; openfile->totsize = totsize_save; #ifndef NANO_TINY if (openfile->mark_set) { @@ -2316,6 +2314,9 @@ void do_justify(bool full_justify) /* Put the keystroke back into the queue. */ unget_kbinput(kbinput, meta_key, func_key); + /* Set the desired screen column (always zero, except at EOF). */ + openfile->placewewant = xplustabs(); + #ifndef NANO_TINY /* Throw away the entire undo stack, to prevent a crash when * the user tries to undo something in the justified text. */ diff --git a/src/winio.c b/src/winio.c index 3f4f9a6130d7bd9dc736a42be721480cc281d896..a67f365b498c59cbb0411e7a6102ccc28efbbc78 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2958,8 +2958,12 @@ void edit_scroll(scroll_dir direction, ssize_t nlines) /* Update any lines between old_current and current that need to be * updated. Use this if we've moved without changing any text. */ -void edit_redraw(filestruct *old_current, size_t pww_save) +void edit_redraw(filestruct *old_current) { + size_t was_pww = openfile->placewewant; + + openfile->placewewant = xplustabs(); + /* If the current line is offscreen, scroll until it's onscreen. */ if (openfile->current->lineno >= openfile->edittop->lineno + maxrows || openfile->current->lineno < openfile->edittop->lineno) @@ -2980,7 +2984,7 @@ void edit_redraw(filestruct *old_current, size_t pww_save) #endif /* !NANO_TINY */ /* Update old_current and current if we've changed page. */ - if (need_screen_update(0) || need_screen_update(pww_save)) { + if (need_screen_update(0) || need_screen_update(was_pww)) { update_line(old_current, 0); update_line(openfile->current, openfile->current_x); }