nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] text: keep cursor at left edge when it is there whe


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] text: keep cursor at left edge when it is there when indenting/commenting
Date: Sun, 10 Dec 2017 14:56:05 +0100

Suggested-by: Brand Huntsman <address@hidden>
---
 src/text.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/text.c b/src/text.c
index c9a5a923..7939ed85 100644
--- a/src/text.c
+++ b/src/text.c
@@ -282,9 +282,9 @@ void indent_a_line(filestruct *line, char *indentation)
     openfile->totsize += indent_len;
 
     /* Compensate for the change in the current line. */
-    if (line == openfile->mark)
+    if (line == openfile->mark && openfile->mark_x > 0)
         openfile->mark_x += indent_len;
-    if (line == openfile->current) {
+    if (line == openfile->current && openfile->current_x > 0) {
        openfile->current_x += indent_len;
        openfile->placewewant = xplustabs();
     }
@@ -584,9 +584,9 @@ bool comment_line(undo_type action, filestruct *line, const 
char *comment_seq)
        openfile->totsize += pre_len + post_len;
 
        /* If needed, adjust the position of the mark and of the cursor. */
-       if (line == openfile->mark)
+       if (line == openfile->mark && openfile->mark_x > 0)
            openfile->mark_x += pre_len;
-       if (line == openfile->current) {
+       if (line == openfile->current && openfile->current_x > 0) {
            openfile->current_x += pre_len;
            openfile->placewewant = xplustabs();
        }
@@ -609,13 +609,13 @@ bool comment_line(undo_type action, filestruct *line, 
const char *comment_seq)
        openfile->totsize -= pre_len + post_len;
 
        /* If needed, adjust the position of the mark and then the cursor. */
-       if (line == openfile->mark) {
+       if (line == openfile->mark && openfile->mark_x > 0) {
            if (openfile->mark_x < pre_len)
                openfile->mark_x = 0;
            else
                openfile->mark_x -= pre_len;
        }
-       if (line == openfile->current) {
+       if (line == openfile->current && openfile->current_x > 0) {
            if (openfile->current_x < pre_len)
                openfile->current_x = 0;
            else
-- 
2.14.3




reply via email to

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