jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

Bug fix: `View.writeRune` appends stray `\x00` when writing to the end of a line #113

Closed rlisagor closed 7 years ago

rlisagor commented 7 years ago

The cause was that the line array was extended twice when writing at the end of a line - once in the first if clause because the cursor is beyond the end of the line, and then again in the second if clause dealing with the Overwrite condition.

This change makes the two if clauses mutually exclusive.

Please let me know what you think or if you'd like me to make any changes.

jroimartin commented 7 years ago

I've been testing this PR with _examples/bufs.go and looks like it introduces the following bug when v.Wrap = true:

1.- Run go run _examples/bufs.go and set the view as follows:

screen shot 2017-08-15 at 21 27 59

2.- Start writing at the end of the first line. After reaching the end of the line, the edition continues in the following line (just before B) without adding a new line:

screen shot 2017-08-15 at 21 28 14

3.- If you do the same test with master:

screen shot 2017-08-15 at 21 28 57

This is because edit.go should be rewritten taking into account the wrapping mode (that was introduced later) as well as other features like multi-width characters, etc.

jroimartin commented 7 years ago

More context: #69, #80, #90, #60

jroimartin commented 7 years ago

Fixed via 2677ad04454bb2a43069dda0675b602b0ec2c14c. Can you check? :)

rlisagor commented 7 years ago

Works for me, thanks for the fix!