Commit 440a128d authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

indenting: keep affecting last line of marked region if it was at first

When unindenting/uncommenting affected the bottom line of the marked
region, keep affecting this line also during subsequent consecutive
indenting/commenting.

This fixes https://savannah.gnu.org/bugs/?52718.
parent 4f2b01c7
Showing with 18 additions and 9 deletions
+18 -9
...@@ -67,7 +67,9 @@ char *title = NULL; ...@@ -67,7 +67,9 @@ char *title = NULL;
bool more_than_one = FALSE; bool more_than_one = FALSE;
/* Whether more than one buffer is or has been open. */ /* Whether more than one buffer is or has been open. */
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
int didfind = 0; int didfind = 0;
/* Whether the last search found something. */ /* Whether the last search found something. */
......
...@@ -1698,13 +1698,16 @@ int do_input(bool allow_funcs) ...@@ -1698,13 +1698,16 @@ int do_input(bool allow_funcs)
/* Execute the function of the shortcut. */ /* Execute the function of the shortcut. */
s->scfunc(); s->scfunc();
#ifndef NANO_TINY #ifndef NANO_TINY
/* If Shiftless movement occurred, discard a soft mark. */ /* When the marked region changes without Shift being held,
if (!shift_held && openfile->mark && * discard a soft mark. And when the marked region covers a
openfile->kind_of_mark == SOFTMARK && * different set of lines, reset the "last line too" flag. */
(openfile->current_x != was_x || if (openfile->mark && (openfile->current != was_current ||
openfile->current != was_current)) { openfile->current_x != was_x)) {
openfile->mark = NULL; if (!shift_held && openfile->kind_of_mark == SOFTMARK) {
refresh_needed = TRUE; openfile->mark = NULL;
refresh_needed = TRUE;
} else if (openfile->current != was_current)
also_the_last = FALSE;
} }
#endif #endif
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
......
...@@ -54,6 +54,8 @@ extern char *title; ...@@ -54,6 +54,8 @@ extern char *title;
extern bool more_than_one; extern bool more_than_one;
extern bool also_the_last;
extern int didfind; extern int didfind;
extern int controlleft; extern int controlleft;
......
...@@ -541,8 +541,10 @@ void get_range(const filestruct **top, const filestruct **bot) ...@@ -541,8 +541,10 @@ void get_range(const filestruct **top, const filestruct **bot)
mark_order(top, &top_x, bot, &bot_x, NULL); mark_order(top, &top_x, bot, &bot_x, NULL);
if (bot_x == 0 && *bot != *top) if (bot_x == 0 && *bot != *top && !also_the_last)
*bot = (*bot)->prev; *bot = (*bot)->prev;
else
also_the_last = 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