vscode-paste-and-indent
vscode-paste-and-indent copied to clipboard
End of pasted text is auto-selected
Step to reproduce:
- Copy at least 2 lines without any indentation
- Paste&Indent them on a indented with
n
spaces - 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.
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!
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 yeah this is intended if you have enabled the selectAfter
option.
It is kinda weird, why it is not select the pasted text instead?
@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).
I find this occurs even with selectAfter
disabled.
@rubymaniac have you found a solution?
No I haven't had the time to look into it. If anyone is willing to look into it would be awesome.
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