vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Ctrl+C on blank empty line copies new line and overwrites clipboard

Open vsccarl opened this issue 10 years ago • 3 comments

OS: Windows 10 Build#: 0.10.12-alpha Node: 4.1.1

As the title says, if you have already copied something and you Ctrl+C on a separate blank line, it will overwrite your clipboard and hold a newline character. Normally when you copy with the cursor not selecting anything on a new line, it will hold your previous copy.

vsccarl avatar Mar 11 '16 19:03 vsccarl

This is by design. Ctrl+C without selection will place current line in clipboard. If you are on an empty line, it will place a newline character in clipboard.

alexdima avatar Mar 14 '16 08:03 alexdima

Hi @alexandrudima , do you know if something has changed prior to 0.10.11 about it?

I had an extension Copy Word in Cursor that is meant to replace the Copy and Cut commands when there is no selection. It automatically selects the word where the cursor is, and copies/cuts to the clipboard, but I just noted that it is not working anymore :cry: . It detects and select the word, but when I call vscode.commands.executeCommand("editor.action.clipboardCopyAction");, it does not respect the new selection, and the whole line is copied to the clipboard strangely, if I use the clipboardCutAction command, it cuts the selected word, but the clipboard is filled with the entire line, again.

I don't know if the commands itself changed, or if I have to do something else after updating the selection. The code is basically:

  const cursorWordRange = doc.getWordRangeAtPosition(selection.active);
  var newSe = new vscode.Selection(cursorWordRange.start.line, cursorWordRange.start.character, cursorWordRange.end.line, cursorWordRange.end.character);
  editor.selection = newSe;
  vscode.commands.executeCommand("editor.action.clipboardCutAction");

Thanks for your help.

alefragnani avatar Mar 17 '16 02:03 alefragnani

@alefragnani I've created #4393 to track the problem.

alexdima avatar Mar 17 '16 22:03 alexdima