Open Bug 1593761 Opened 6 years ago Updated 2 years ago

CodeMirror doesn't interact correctly with PRIMARY on Linux

Categories

(Core :: DOM: Selection, defect, P3)

Unspecified
Linux
defect

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

Details

STEPS TO REPRODUCE:

  1. Open console (e.g. by doing Ctrl+Shift+I)
  2. Type some stuff
  3. Select that stuff
  4. Middle-click in some other application

EXPECTED RESULTS: The selected stuff is pasted

ACTUAL RESULTS: Whatever was selected before step 3 is pasted.

It looks like selecting in the console doesn't place things in PRIMARY, unlike every single other editable area?

This makes it pretty hard to copy data out of the console into bug reports...

This used to be a bug report on scratchpad (bug 1466837), but if console is supposed to be the replacement ... it has the same issue.

Thanks for the bug report Boris.
The issue is probably in CodeMirror, which was used in Scratchpad, and is also used in Console (and debugger, style editor, …)
I'll try to address that and backport it in the CodeMirror lib.

Priority: -- → P3
Component: Console → Source Editor
OS: Unspecified → Linux
Summary: Console doesn't interact correctly with PRIMARY on Linux → CodeMirror doesn't interact correctly with PRIMARY on Linux

I don't think this is necessarily CodeMirror. For example, https://jsfiddle.net/Sk8erPeter/TcqAf/ works just fine with PRIMARY. The issue is more likely to do with whatever chrome document this stuff is running in and how it's set up.

Summary: CodeMirror doesn't interact correctly with PRIMARY on Linux → Source Editor doesn't interact correctly with PRIMARY on Linux
See Also: → 1594661

(In reply to Boris Zbarsky [:bzbarsky] from comment #2)

I don't think this is necessarily CodeMirror. For example, https://jsfiddle.net/Sk8erPeter/TcqAf/ works just fine with PRIMARY. The issue is more likely to do with whatever chrome document this stuff is running in and how it's set up.

Didn't notice back then but the fiddle is broken (CodeMirror isn't loaded because of mixed content)
If you try with this demo https://jsfiddle.net/zndp9qk2/ , it doesn't work on Firefox, but does on Chrome.

It impacts all the apps using codeMirror like CodePen, jsbin, …

I'm not sure how text selection is handled in CodeMirror, but it doesn't change the document.getSelection() result.

Marijnh, are you doing anything specific to make the text selection available on primary?

Component: Source Editor → DOM: Selection
Flags: needinfo?(marijnh)
Product: DevTools → Core
Summary: Source Editor doesn't interact correctly with PRIMARY on Linux → CodeMirror doesn't interact correctly with PRIMARY on Linux

CodeMirror (in desktop mode) focuses a hidden textarea, and creates a selection inside that. Since getSelection doesn't integrate with text selections inside input and textarea elements, you won't see your selection reflected there.

Programmatically setting a selection in a textarea doesn't change the X primary selection in Firefox, but it does in Chrome. I haven't found any way to work around that.

Flags: needinfo?(marijnh)

Thanks for the quick answer Marijn, let's see if the DOM team folks can shine a light on that.

The severity field is not set for this bug.
:hsinyi, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(htsai)
Severity: normal → S3
Flags: needinfo?(htsai)

Note that this also affects the Debugger UI (as reported in Bug 1699839)

I see both this issue and the reverse:

  1. Select text with mouse in some other application
  2. Middle-click to paste in console

I also see the same buggy behavior in code editor components used on web sites like CodeMirror, CodeJar, Ace, and Monaco. This affects web-based code editing environments like vscode.dev.

Plenty of us still use mouse selection and paste on Linux, despite the relatively low activity of this bug!

You need to log in before you can comment on or make changes to this bug.