question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deletion of selected text deletes unselected text [bug]

See original GitHub issue

Description

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

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): image

Press the down arrow to select the first two lines: image

Press the backspace key: image

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:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fxhacommented, Jan 2, 2022

Reference text:

The

e

The2
door banged open and a man strode in.

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 to e with offset 1. On the other hand the keyboard selection ends in paragraph The2 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 first T.

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

Soft-line-breaks in MarkText:

Soft-lines are rendered in MarkText as separated text lines that are separated by a newline (.ag-soft-line-break) which contains \n. A user can now edited the different lines, add or remove soft-lines.

<span id="ag-101" class="ag-paragraph ag-active ag-paragraph-content">
  <span class="ag-plain-text">The2</span>
  <span class="ag-soft-line-break">\n</span>
  <span class="ag-plain-text">door banged open and a man strode in.</span>
</span>

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?

1reaction
tenbobcommented, Dec 31, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Macro problem in Word 2013 - Microsoft Community
It works fine for deleting selected text. ... know you want to delete objects, I guess the big bug is that unselected objects...
Read more >
Why unselected photos delete within a tex… - Apple Community
When I go into a text thread and select 2 different texts to delete that aren't one right after the other, if there...
Read more >
Selecting Text Deletes it When Typing Over It - 352801
I'm wring text, something is misspelled so I right click on it to fix it, and everything deletes. Or here is another example:...
Read more >
Fixed Deleting Texts As You Type in Word Document - YouTube
Hi, this video gonna help you to stop deleting texts as you type or spacebar keeps on deleting texts when you press on...
Read more >
107857 – Incorrect formatting logic when replacing formatted ...
Bugzilla – Bug 107857 Incorrect formatting logic when replacing formatted selected text (should be true replace instead of delete+insert) Last modified: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found