GNOME Bugzilla – Bug 624963
(Still) Incorrect line shifting
Last modified: 2017-03-30 15:33:08 UTC
I reported a line shifting bug in an earlier bug report: http://bugzilla.gnome.org/show_bug.cgi?id=601889 After having seen the bugfix in gedit 2.30.3 on Ubuntu 10.04, I believe the current behavior is still not (entirely) correct. For example, if the text file contains the following 3 lines: first line second line third line and I press Alt + Arrow Up on the third line, the third and the second line are swapped correctly. What's incorrect is that gedit also adds an empty fourth line after the third line. I find this behavior slightly irritating, but of course that's only a minor issue. Thanks for listening and for the hard work :)
I can confirm this. I would have to investigate what's producing this.
Still a problem with gedit 3.14.
I try but , i dont know if the code "line shifting" (shortcut : alt +up) is in the source code of gedit (I have not found any line that mentions) or if it is gtk thing, I have done a bit of compilation of the bug http://akanooblinux.blogspot.pe/
Created attachment 348438 [details] [review] This patch fixes the bug, in the gtksourceview for the change of lines Cleaning the \n from buffer
I can confirm this patch resolves the bug, I apply the patch to last gtksourceview code and testing the behavior and is better. I reassign to GtkSourceView because this issues too affects to other GNOME Apps like Builder and Latexila.
Review of attachment 348438 [details] [review]: Thanks for the patch. Even if it works, it is not of sufficiently good quality to be included as-is. First, the patch needs to be generated with the git format-patch command, read the README and HACKING files. ::: gtksourceview/gtksourceview.c @@ +3692,3 @@ gboolean down; gchar *text; + gboolean First_case = 0; variable names should be in lowercase. As a general rule of thumb, use the same coding style as the current file (it is explained in the HACKING file). Also, a gboolean can receive the FALSE and TRUE values, more meaningful than 0 and 1. @@ +3789,3 @@ { gtk_text_iter_backward_line (&e); + if( First_case ) It sucks to have a big block of code for the special case. I think it's possible to implement this function more easily. @@ -3793,3 @@ gtk_text_buffer_delete_mark (buf, mark); } - Apparently you removed a line that you should not have removed. Please read the diff more carefully when submitting a patch.
I've started to write unit tests. I think that for the handling of the final newline, the code can be simplified with something along those lines: gboolean initially_contains_final_newline = ...; if (!initially_contains_final_newline) { /* insert a final newline */ } /* Do the change, at this point the buffer always contains a final newline, so the implementation will be simpler. */ if (!initially_contains_final_newline) { /* remove the final newline */ }
Fixed: commit bc554dcac5a4f5b80918b7584c37f8e70342b5b0