Open php4fan opened 3 months ago
Hello,
Interesting. Unfortunately, we are unable to replicate this. Have you noticed any pattern when does this happen or is it completely random?
Thanks!
It seems to depend on: 1) whether you copy the first line in its entirety including all the trailing spaces, or without the trailing spaces, or with only some 2) whether you paste it at the very beginning of the empty line, or at the end of the whitespace that's already in the empty line (if any), or somewhere in the middle
But not in a way that seems to make sense. Probably for each of the combinations above you'll get consistent results if you repeat consistently the same action, but not in a way that I would be able to guess. And either way I don't see a good reason for not just always adjusting indentation regardless of how much trailing space you copied or where exactly in a line only made of whitespace you paste it. Not when copying multiple lines.
Cutting this:
Pasting here:
Result: (bad)
Cutting this:
Pasting here: (there are white spaces after the cursor BTW)
Result (good):
Cutting this:
Pasting here:
Result: (good)
Were you able to reproduce with the hints in my last comment?
Hello,
I think format on paste is turned off. Please try to turn it on and the behavior should stay consistent across all the cases.
"[php]": {
"editor.formatOnPaste": true
}
It is indeed turned off, but I don't see how the current behavior makes any sense even with that option turned off.
If not formatting on paste means not touching any formatting including the indentation, then I'd expect the code to be always pasted as-is without changing the indentation, in all cases. If it means don't reformat but still do adjust indentation (which is what one would normally want in most cases), then I'd expect it to adjust indentation properly, again always.
That's a valid point. We will investigate the factors contributing to this behavior. It's possible that Visual Studio Code has default rules aimed at maintaining proper indentation, but their effectiveness may vary.
Given the following code:
}
that precedes the copied code.Expected: the indentation of the pasted code should automatically be adjusted.
Observed: this:
Only the indentation of the first pasted line has been adjusted, the rest was copied as-is.
This doesn't always happen. Often I get the expected behavior, but I don't know what makes the difference. It's not the presence of syntax errors, as you can see there are none in the example above.