microsoft/monaco-editor

Text truncated on copy with "..." ellipsis

pombredanne opened this issue · 15 comments

monaco-editor version: See below
Browser: Firefox 68.0.1 (64-bit)
OS: Linux

Steps or JS usage snippet reproducing the issue:

Copy some long enough text ... and paste it: it gets truncated in the middle with dot dot dot ellipsis. On Chrome this is not truncated. Only on FF.

This seems to be closely related to #1458

This is the version used in ClearlyDefined: https://clearlydefined.io/vs/editor/editor.main.js

/*!-----------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.10.1(ebbf400719be21761361804bf63fb3916e64a845)
 * Released under the MIT license
 * https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
 *-----------------------------------------------------------*/

This is the version used in Azure: https://cdn.vsassets.io/3rdParty/_content/Extensions/CodeEditor/0.13.1.1/vs/editor/editor.main.js

/*!-----------------------------------------------------------
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Version: 0.13.2(53a4043676e6259fb734c90fad14bf16f7425640)
 * Released under the MIT license
 * https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
 *-----------------------------------------------------------*/

Note that this is still an issue in v 0.17.0

Note the we litterally have an Ellipsis codepoint https://en.wikipedia.org/wiki/Ellipsis not a dotdotdot

@alexandrudima as the main author, would you by chance have an idea of where to look for in the code to fix this?

Thank you in advance!

This is a pending bug in clearlydefined/website#799 which happens to be sponsored and used also by MSFT and GH FWIW.

And that same issue exists in Azure pipelines when viewing logs: you cannot copy them... the copy is truncated.

Currently the selection clipboard is not supported in linux. Let's track in #1458

@alexdima you wrote:

Currently the selection clipboard is not supported in linux. Let's track in #1458

I am not sure I get what you mean: can you elaborate a bit?
Thanks!

Also this ticket is about Firefox on Linux. There is no issue on Chrome for this. So this is browser specific and not only Linux. #1458 is about Chrome and I cannot reproduce the issue at play here in Chrome.
Do you mind to reopen this ticket?

@pombredanne Here is where we write ellipsis to the hidden <textarea>: https://github.com/microsoft/vscode/blob/cc1ba3c0215af60ad3574baaa3223c9f1875d964/src/vs/editor/browser/controller/textAreaState.ts#L240-L287

That is the text that is placed in the hidden <textarea> that we use for input. We cannot place in there a large body of text because browsers are too slow. That text (from the <textarea>) makes it to the Linux selection clipboard AFAIK. That is to say if Ctrl+C is used, we write the full selected text to the clipboard event.

Can you please clarify your steps? How do you copy the text and paste it in the sentence: "Copy some long enough text ... and paste it"

Are you using:

  • selection clipboard + middle mouse click
  • Ctrl+C and Ctrl+V
  • right click copy and Ctrl+V
    etc.

@alexdima here is the sequence of events on Firefox 70.0.1 (64-bit) on Ubuntu 16.04 LTS:

  1. click to focus inside the editor
  2. press Shift key, keep pressed
  3. then press Arrow down key to select lines. Select lines until the text scrolls by at least one line (e.g. meaning the selection is larger than what can be seen on screen)
  4. release Shift and Arrow down keys
  5. Press Ctrl+C
  6. Go elsewhere with Alt+Tab to open some text editor, press Ctrl+V

With this sequence, the pasted text is truncated and there is a ellipsis instead on the last line of the pasted text.

For 5. I can use instead (right click or Shift+F10) + copy from the pop-up menu and Ctrl+V or paste to get the same results. Same if I use FF main menu edit/copy option.

I am not using the selection clipboard nor middle mouse click (in fact this is an X "feature" that is disabled in most Linux desktop these days AFAIK and disabled on mine by default).

@pombredanne I cannot reproduce. I have tried:

I have tried with Firefox 70.0.1 (64-bit) on Ubuntu 19.10

Doing the same thing I get this paste:

/* Game of Life
 * Implemented in TypeScript
 * To learn more about TypeScript, please visit http://www.typescriptlang.org/
 */
 
module Conway {

	export class Cell {
		public row: number;
		public col: number;
…	}
}

var game = new Conway.GameOfLife();

We can have a screen sharing session at your convenience if that can help you debug this.

@pombredanne Have you customized your FF profile in any way, such as to disable clipboard APIs? Can you please first attempt to reproduce with a clean FF profile and without any extensions? Does this reproduce for you on Chromium on the same machine?

Can you reproduce in the page at https://vscode-web-test-playground.azurewebsites.net/ (that one has a more up-to-date version of the editor).

Can you also please try running the following fiddle -- https://jsfiddle.net/4mv1wrab/

  • open dev tools
  • click inside the textarea and make a selection
  • press ctrl+c
  • let me know what the console says and what the clipboard contains.

For me, the console says setting text via e.clipboardData and the clipboard contains some other text 1

Thank you!

@alexdima you nailed it and I am very sorry for having wasted your time here.

The culprit are my settings. I have checked my config and found that the setting dom.event.clipboardevents.enabled was set to False to avoid clipboard hijacking from malicious websites. If I enable it, the copy/paste works OK in the fiddle and everywhere.

Things works also fine as-is in Chrome and Chromium.

Please accept my apologies and thank you for your patience!

No problem, glad I could help.