]> git.wh0rd.org Git - nano.git/commitdiff
better handle position shifting when unindenting marked text
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Fri, 5 May 2006 14:22:42 +0000 (14:22 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Fri, 5 May 2006 14:22:42 +0000 (14:22 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

src/text.c

index dedde3a1609ab3e2ac8ed127ce3f9f7c38832e24..409479fe24f10b2b8088055dc25685339a4b209c 100644 (file)
@@ -286,14 +286,20 @@ void do_indent_marked(ssize_t cols)
 
                /* Keep track of the change in the current line. */
                if (f == openfile->mark_begin &&
-                       openfile->mark_begin_x > indent_new &&
-                       openfile->mark_begin_x >= indent_shift)
-                   openfile->mark_begin_x -= indent_shift;
+                       openfile->mark_begin_x > indent_new) {
+                   if (openfile->mark_begin_x <= indent_len)
+                       openfile->mark_begin_x = indent_new;
+                   else
+                       openfile->mark_begin_x -= indent_shift;
+               }
 
                if (f == openfile->current && openfile->current_x >
-                       indent_new && openfile->current_x >=
-                       indent_shift)
-                   openfile->current_x -= indent_shift;
+                       indent_new) {
+                   if (openfile->current_x <= indent_len)
+                       openfile->current_x = indent_new;
+                   else
+                       openfile->current_x -= indent_shift;
+               }
 
                /* We've unindented, so set indent_changed to TRUE. */
                if (!indent_changed)