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.

selecting text, then changing applications, then regaining focus replaces selected text by a single "-"

See original GitHub issue

This bug is similar to #1730 and #2481, and is serious because it can lead to data loss.

Highlight everything in a sufficiently large codemirror editor instance (e.g., http://codemirror.net/demo/complete.html), focus on another application, then come back, and sometimes the contents of the editor is replaced by a -.

I was able to sometimes see this same problem several times with http://codemirror.net/demo/complete.html, though rarely. I will keep trying to make this more clearly reproducible. I’m reporting this mainly in the hopes that it’ll be useful to somebody, and perhaps you could better explain the mysterious code in codemirror.js around

minimal = hasCopyEvent &&

More details and a workaround…

Sometimes users of SageMathCloud (using Codemirror 4.x) have complained that their entire file was replaced by a dash. I’ve never seen this myself, so I didn’t understand how it could happen. It turns out, they copied the contents of a file from Codemirror (via select all) to an external editor, then come back to SageMathCloud, changed tabs in SageMathCloud (which causes a focus event in CodeMirror), and find that their file is replaced by a -. I never saw this because I do all my editing in CodeMirror. With SMC, this happens every single time, and is pretty disturbing. It only happens on Chrome and Safari (at least it doesn’t happen on Firefox).

Since this is a pretty significant problem (the whole file is deleted), as a workaround, I replaced the line in codemirror.js

minimal = hasCopyEvent &&

by

minimal = false && hasCopyEvent && 

Doing this completely stops the problem from happening (not surprisingly, looking at the source code). Of course this causes another problem, where the sometimes selection vanishes when returning to the browser – however, that is a much less serious bug.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nomennesciocommented, Jul 8, 2017

I’ve also found why this bug triggered. It seems to be due to a Chrome plugin https://github.com/jswanner/DontFuckWithPaste

Adding the site to the ‘exclude URL pattern’ list, will not trigger the bug. It is probably due to assumptions on your part about an expected series of events, which that plugin changes.

0reactions
guiambroscommented, Jul 12, 2017

DFWP seems to completely disable all copy/cut/paste events.

Exactly. DFWP disable clipboard events, in order to block sites from nefarious or annoying behaviors – e.g., forms not allowing you to paste in password confirmation field.

In this case, even with DFWP enabled, the copy & paste still worked with <1000 characters. It was only over this limit that the JS injected by DFWP triggered the hidden textarea hack in CM, resulting in the "-".

Anyway, I agree with the sentiment; you’re certainly asking for trouble when you install a Chrome extension that modifies your clipboard behavior – even if the intent is to restore its original functionality 😃

Thanks for the quick patch! Much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

linkedin-skill-assessments-quizzes/microsoft-word-quiz.md at ...
On Mac: With the style pane open, highlight a Heading 1 in the document, then in the style pane drop-down for Heading 11,...
Read more >
Select text - Microsoft Support
Select text by using the mouse ; A large block of text. Click at the start of the selection, scroll to the end...
Read more >
Keep text selected when focus input - javascript - Stack Overflow
it can change both. 1. because demanding to have a focus on more than one single aim/task/subject on a single turn, is absurd,...
Read more >
Selecting and Moving Text | Computer Applications for ...
Right-click selected text, select either Copy or Cut, then right-click the new location of text and select Paste.
Read more >
This video explains how to select text and change case in ...
The tutor demonstrates several different ways to select text in Microsoft Word. Using the selection area to select a line, paragraph or the ......
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