nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] indenting: keep affecting last line of marked regio


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] indenting: keep affecting last line of marked region if it was at first
Date: Sun, 24 Dec 2017 12:33:03 +0100

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.
---
 src/global.c |  4 +++-
 src/nano.c   | 15 +++++++++------
 src/proto.h  |  2 ++
 src/utils.c  |  4 +++-
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/global.c b/src/global.c
index 38c110be..e2cef68f 100644
--- a/src/global.c
+++ b/src/global.c
@@ -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. */
 
diff --git a/src/nano.c b/src/nano.c
index de4d7a7a..90b28e6c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1699,12 +1699,15 @@ int do_input(bool allow_funcs)
            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;
+           if (!shift_held && (openfile->current != was_current ||
+                               openfile->current_x != was_x)) {
+               if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
+                   openfile->mark = NULL;
+                   refresh_needed = TRUE;
+               }
+
+               /* And forget about the last line of the marked region. */
+               also_the_last = FALSE;
            }
 #endif
 #ifdef ENABLE_WRAPPING
diff --git a/src/proto.h b/src/proto.h
index a6338380..608ccddd 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -54,6 +54,8 @@ extern char *title;
 
 extern bool more_than_one;
 
+extern bool also_the_last;
+
 extern int didfind;
 
 extern int controlleft;
diff --git a/src/utils.c b/src/utils.c
index 771f58ae..4ae36f4f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -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;
     }
 }
 
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]