[BUG] Disappearing of first line after Ctrl-Y

Dmitry Semyonov Dmitry.Semyonov at oktet.ru
Wed Nov 6 16:53:47 UTC 2002


Hello, Pavel.

The patch for edit.c that fixes all the discribed problems is attached.
At the same time I think that 'Ctrl-Y F3' related bug was just shaded
out but not fixed.

The pathch was produced via
'LC_ALL=C TZ=UTC0 diff -Naur edit.c edit.c.new > edit.c.patch'
command agains 1.42 version of edit.c.

Use 'patch < edit.c.patch' inside 'edit' directory to apply the patch.

BTW, I was not able to find any guidelines or links on how to produce
patches for mc both on mc web site and inside mc sources. So, apologies
if I did something wrong.


On Sun, 3 Nov 2002, Pavel Roskin wrote:

> > Sometimes 1st (on the screen, not in file) line of edited text
> > disappears after pressing Ctrl-Y (or Ctrl-Del) on it. (Cursor moves down
> > in this case, and topmost line is to be updated with a line just before
> > erased one, but it isn't sometimes.)
> >
> > I experienced the bug after making M-? search, and trying to edit found
> > files.
>
> If you see the implementation of edit_delete_line(), it emulates pressing
> backspace until it meets a newline.  The do..while loop means that the
> newline is erased.  Then it's re-added.  Obviously, it you are on the
> first (on screen) line and you the newline, the screen scrolls so that you
> can see the previous line.
>
> I agree that this behavior is not what the user expects, but it's a very
> minor issue.  Feel free to fix it.  Just check if you reach the beginning
> of the string before calling edit_backspace().  Then you won't need to
> insert '\n' at the end of edit_delete_line().

[...]

> > Actually I am not able to reproduce the bug every time exactly the
> > same way as described (i.e. just pressing Ctrl-Y), but the first line is
> > also cleared after Ctrl-Y F3 (and Ctrl-Y Ctrl-O Ctrl-O), and I think this is
> > related to the original bug. (Note that Ctrl-Y is to be pressed on the
> > first displayed line.)
>
> I see.  That's a more serious bug.  That's why it's important to describe
> how to reproduce the bug for sure.  What I wrote before was just about the
> fact that the line comes from the above, not from below, to replace the
> removed line.


...Bye..Dmitry.
-------------- next part --------------
--- edit.c	Wed Nov  6 16:33:21 2002
+++ edit.c.new	Wed Nov  6 16:34:44 2002
@@ -1770,14 +1770,20 @@
 void edit_delete_line (WEdit * edit)
 {
     int c;
+
+    /* Delete right part of the line (including '\n' char) */
     do {
-	c = edit_delete (edit);
-    } while (c != '\n' && c);
-    do {
-	c = edit_backspace (edit);
+        c = edit_delete (edit);
     } while (c != '\n' && c);
-    if (c)
-	edit_insert (edit, '\n');
+    
+    /*
+     * Delete left part of the line.
+     * Note, that edit_get_byte() returns '\n' when byte position is < 0.
+     */
+    while (edit_get_byte (edit, edit->curs1 - 1) != '\n')
+    {
+        (void) edit_backspace (edit);
+    };
 }
 
 static void insert_spaces_tab (WEdit * edit, int half)


More information about the mc-devel mailing list