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.
master
Benno Schulenberg 2017-12-24 12:26:55 +01:00
parent 4f2b01c7e5
commit 440a128d25
4 changed files with 18 additions and 9 deletions

View File

@ -67,7 +67,9 @@ char *title = NULL;
bool more_than_one = FALSE;
/* 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;
/* Whether the last search found something. */

View File

@ -1698,13 +1698,16 @@ int do_input(bool allow_funcs)
/* Execute the function of the shortcut. */
s->scfunc();
#ifndef NANO_TINY
/* If Shiftless movement occurred, discard a soft mark. */
if (!shift_held && openfile->mark &&
openfile->kind_of_mark == SOFTMARK &&
(openfile->current_x != was_x ||
openfile->current != was_current)) {
openfile->mark = NULL;
refresh_needed = TRUE;
/* When the marked region changes without Shift being held,
* discard a soft mark. And when the marked region covers a
* different set of lines, reset the "last line too" flag. */
if (openfile->mark && (openfile->current != was_current ||
openfile->current_x != was_x)) {
if (!shift_held && openfile->kind_of_mark == SOFTMARK) {
openfile->mark = NULL;
refresh_needed = TRUE;
} else if (openfile->current != was_current)
also_the_last = FALSE;
}
#endif
#ifdef ENABLE_WRAPPING

View File

@ -54,6 +54,8 @@ extern char *title;
extern bool more_than_one;
extern bool also_the_last;
extern int didfind;
extern int controlleft;

View File

@ -541,8 +541,10 @@ void get_range(const filestruct **top, const filestruct **bot)
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;
else
also_the_last = TRUE;
}
}