vscode-paste-and-indent icon indicating copy to clipboard operation
vscode-paste-and-indent copied to clipboard

End of pasted text is auto-selected

Open zessx opened this issue 8 years ago • 9 comments

Step to reproduce:

  1. Copy at least 2 lines without any indentation
  2. Paste&Indent them on a indented with n spaces
  3. The pasted text is well indented, but has now the n last chars selected

Example (from a new file):

<?php
// Copy these two lines
$bar = 2; 
$baz = 3;

if (true) {
  $foo = 1;
  // Paste them here
}

Here, the indentation is 2 spaces, so the chars 3; will be selected.

This is really annoying, as it's quite specific, and I need to check every copy/paste to ensure I won't erase parts of my code.

zessx avatar Feb 27 '17 14:02 zessx

I have stumbled upon this issue myself. It is not clear (at least to me) under which conditions the selection happens but it has something to do with selections being unstable but I will have to investigate further. I will update this issue with details!

rubymaniac avatar Mar 01 '17 16:03 rubymaniac

Mine have different behaviour. If I copy and paste n lines it will select only 2nd line to n-th line. So if if I copy one line it did not select anything at all.

supirman avatar Mar 19 '17 02:03 supirman

@supirman yeah this is intended if you have enabled the selectAfter option.

rubymaniac avatar Mar 19 '17 11:03 rubymaniac

It is kinda weird, why it is not select the pasted text instead?

supirman avatar Mar 19 '17 15:03 supirman

@supirman because this option is there if you usually find yourself copypasting code that has the first and the last line on different indentation levels like it is the case for offset sensitive languages (Python, YAML etc).

rubymaniac avatar Mar 20 '17 11:03 rubymaniac

I find this occurs even with selectAfter disabled.

varkor avatar Jun 27 '17 17:06 varkor

@rubymaniac have you found a solution?

mignz avatar Jan 07 '18 14:01 mignz

No I haven't had the time to look into it. If anyone is willing to look into it would be awesome.

rubymaniac avatar Feb 10 '18 18:02 rubymaniac

Heads up: I just released a new Indent on Paste extension that basically does the same thing as this, but takes a different approach that should hopefully circumvent these odd edge case bugs. It's not well tested yet, so it might have some weird bugs of its own, but feel free to try it out! https://marketplace.visualstudio.com/items?itemName=gazugafan.vscode-indent-on-paste

gazugafan avatar Jun 09 '18 22:06 gazugafan