[BUG] Disappearing of first line after Ctrl-Y

Pavel Roskin proski at gnu.org
Mon Nov 4 04:38:04 UTC 2002


Hello!

> 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().

> (BTW, it is not handy that found line is displayed at the topmost
> line of the screen. It would be better to have it somewhere after 1/3
> part of the screen.)

No so easy.  This behavior should be implemented in the viewer as well.  
For this to be convenient (i.e. to make it easy for the user to find the
line), you need some highlighting in the viewer and in the editor.

This also means that you cannot use the edit() function that only takes 
one argument - the start line, or you should redefine the behavior of 
"mcedit +number file" so that is would also highlight the specified line 
on startup rather than make it the first line on the screen, as documented 
in the "mc --help" output.

Yes, I know, too old project, too much duplicated code, too many little
details documented for years and "legitimized" by translations in many
languages.  Improving mc is not fun - most simple things have been done.  
But it is possible, and I told you how.

> 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.

I don't think it's critical to fix this bug before 4.6.0, but if you make
a fix, I'll apply it.

-- 
Regards,
Pavel Roskin




More information about the mc-devel mailing list