martes, 14 de febrero de 2017

Ghost Line Bug in gedit

In the documentation of gedit mentions many shortcuts, which only had to fulfill its function without adding something more. In the case of the shortcut ALT + Arrow_UP which should only interchange the line where the cursor is with the line above, this does not happen since it adds a line of more at the end of the text, for example if the original document had 3 lines ( As in the example of replica) when using the shortcut would end with 4 lines.

The shortcuts that gedit provides are following:


Problem
In many cases a plus line is not a major drawback, but if you were reading a set of data where the importance of the number of lines to count is important, as in files used to read a huge string of data for the Training of neurons, this generates an overflow problem.

Replica bug

The bug link found is as follows:
We will see that the following is validated:

Screenshot_11.jpg

The original file has 3 lines as in the posed in the post

Screenshot_12.jpg

When running the shortcut ALT + arrow up let's see how a new phantom line is created when running wc in the test text, which verifies the mentioned bug.


Possible solution found
Hypothesis

The solution seems to be simple, despite not finding exactly the part of the code where it happens.
When you do a row exchange the following happens:

                                                          Line1 / o/n
                                                          Line2 / o/n
                                                          Line3 / o
Where "/ o" is the end of the line in the string and "/ n" is the line break , when the line change is done both a "delete" and "cut" line, storing the two strings to change in the following way:
Linea2 will be exchanged with Line3
      
                                      Line3 is cut and buffered 1: Line3 / o

 The cursor remains where I delete the line (here the error) being at the beginning thus:
                                                          Line1 / o/n
                                                          Line2 / o/n
                                                          |
From here you will copy from the cursor position all the previous string plus the space left at the time of cutting Line3, then:

                                  Line2 + "Space left when cutting" to buffer 2: Line2 / o / n

Here it is appreciated that when "cut" ah is added a character more to the string. Then follows with:

                 
                                                         Line1 / o
Paste buffer1 content:                     Line3 / o
Paste buffer2 content:                    Line2 / o / n

Appreciating more clearly the addiction of the line that causes the bug.

I do not know if it is part of the code of gedit or if it is already part of the use of gtk where is the code of change of lines.
The solution in this case would only be erased when doing the cut in additional line break.

SO:Fedora25

No hay comentarios:

Publicar un comentario