-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not "keep indentation" when pasting #1344
Comments
I can't reproduce that behaviour, looks okay here. So maybe start with the basics and provide all the info the template already asked ? (OS;versions etc) |
Ok, sorry, I assumed that this was by design.. Environment
|
Note that has been the behavior on Windows for as long as I can remember. So, if it's an environment specific thing, the OS should be the only thing that matters. |
I don‘t see that behaviour on windows either |
Hmm weird. You do have "Keep Indentation" selected, right? Here's my |
works as expected with your texstudio.ini |
okay, now I see |
When selecting text and pressing
Ctrl + X
,Ctrl + V
(i.e. cut and paste), I would expect the end result to be the same as when I started. However TeXstudio does not do this in very common situations, namely when newlines are contained in the pasted text and it is pasted on an indented line.I should clarify that I am working with the "Keep Indentation" setting. This does not apply to the "Ignore Indentation" setting (as it does not occur there) or the "Indent and Unindent Automatically" setting (as automatic indentation is explicitly requested there).
The Situation
Ok, so let's look at an example.
Let's say I select everything from the end of the second to the end of the third line (either using the mouse or by putting the cursor at the end of the third line and pressing
Shift + Up
) and pressCtrl + X
,Ctrl + V
. The third line is pasted with double indentation (because the copied indentation is added to the one on the second line, where it is pasted). If I pressCtrl + V
a couple of times more, each line is indented further than the last. We end up with the following.(If one copies the text (
Ctrl + C
) insted of cutting, all the pasted lines will be indented 2 spaces fewer, because the selection is still active then pasting for the first time.)While cutting and pasting lines of code in the same place is rarely useful, cutting it in one place and pasting it at another is a common operation, as is copying some lines and pasting them multiple times. With the current behavior, one has to either unindent the code before cutting/copying or fix the indentation after pasting, both of which is rather tedious. Furthermore, this behavior is rather surprising and confusing (I have never seen it in another text editor and even after years of using TeXstudio I still trip up over this).
The Remedy
I can think of two ways to tackle this problem
One could simply not add the indentation of the current line to each pasted line, i.e. only insert the indentation that was actually copied. For me, this would be the desired behavior in the vast majority of cases. The only time it is not, is when moving code from one level of indentation to another. However, even then this behavior is simple and predictable and having to adjust indentation in such a case seems rather intuitive. (Actually, one usually has to do that with the current behavior, too: Copying lines of code indented by 1 unit and pasting them on a line indented by 2 units will indent the pasted lines by 3 units, not 2.)
One could remember the indentation of the line the code was copied from and try to calculate the "correct" indentation when pasting. This seems rather difficult, though, and couldn't work when pasting text from external applications, which is why I would prefer the first option.
The text was updated successfully, but these errors were encountered: