Deletion of selected text deletes unselected text [bug]
See original GitHub issueDescription
Paragraphs of text disappear when deleting unrelated text. This happens constantly and is an incredibly obnoxious bug. I think there’s multiple ways to cause it to happen, but this is the only one I was able to isolate.
Steps to reproduce
The left is MarkText, the right is gedit, a plain text file editor (to show you the exact contents of the file opened in MarkText).
Start with this. Note that the second “The” and the line starting with “door banged open” have a newline separating them, but not an empty line.
Then put your cursor at the start of the first “the” using the arrow keys (the bug still works with the cursor, but it’s more reliable with the keys):
Press the down arrow to select the first two lines:
Press the backspace key:
Expected behavior:
I expected the line with “The” and the line with “e” to be deleted; that is, I expected the selected lines to be deleted.
Actual behavior:
The selected lines were deleted along with the line starting with “door banged”. Note that the second “The” line did not get deleted.
Versions
- Mark Text: 0.16.1
- Operating system: Ubuntu 18.04
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Reference text:
Given content contains two paragraphs and an additional one that contains also a soft-line (
door banged open and a man strode in.
).Why is there a difference between mouse and keyboard?
The text selection is different using mouse or keyboard because the mouse will select the paragraph starting by
The
toe
with offset 1. On the other hand the keyboard selection ends in paragraphThe2
with offset 0. This can be reproduces in Firefox and Chromium and seems the expected HTML behavior.Reproduce the issue with mouse selection:
The issue occurs with the mouse too by selecting more text in the
The2
paragraph, like the firstT
.Issue description:
tldr: All text removal across several paragraphs that end in a paragraph that contain soft-lines will lose all soft-lines because all text is discard after the first line-break.
Selecting text over several paragraphs that end in a paragraph with soft-line entries will result in a loss of all soft-lines in the ending paragraph because all text is removed after the (soft) line break (that is represended by a newline
\n
in MarkText).The removal is correct if we remove the newline added by
.ag-soft-line-break
, but all soft-lines are merged into one paragraph (all soft-lines are gone). A very dumb workaround is to replace the newline via CSS, but in this case all soft-lines are converted into one big line that wouldn’t be expected by the user. Maybe we can hack this to add a newline in Muya to keep the soft-lines.I think we have to detect this case somehow and handle it manually without passing the removal event back to Chromium because Chromium will remove all content in the paragraph after the first newline/line break. @Jocs Some idea about a possible solution?
I confirm this happens frequently on 0.16.3. Random chunks of text disappear without warning when you do some unrelated editing. As the OP said, this behaviour is quite obnoxious.
Unfortunately, this has undermined my confidence in the software. I can’t work with an editor that randomly corrupts the document. It’s really frustrating. I glimpse something changing on the screen and ask “WTF. What just happened?”.
You can sometimes restore it by switching to source mode and back. But you’re never quite sure it’s exactly what it was before.
This should really be the number one priority to fix.