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
Indentation on pasting of a multiline text #3845
Comments
I think it's an interesting (and probably useful) behavior, but it probably also cannot be the default. Here are a couple of reasons why from the top of my head:
All that might or might not make sense I guess, depending on the situation. I guess the "best" algorithm is one that takes clipboard indentation deltas into account and applies them, but it's also the most complex and could get things wrong. As a currently available workaround (which you might already know about), you can easily adjust indentation of a whole series of lines by selecting it and using Tab or Shift+Tab. |
And what about pasting Python (or other offside languages)? Are we pasting:
So just taking deltas into account is still not enough because of 2. vs 3. Too many choices, but the current behaviour of re-indenting the first line only is likely to be wrong most of the time and probably should be changed for multi-line pastes. |
The current behavior does not indent anything, it just insert whatever there is in the clipboard wherever the caret is at. If the caret was at an indentation, so be it. |
What I mean is that the usual use case is to type return to get a new line to paste on, but that indents with the usual settings for Python, so extra indent is added to the first line unless the user does return then backspaces to remove the indent to start of line and then inserts. Perhaps "re-indent" is the wrong term but the default result is to add indent to the first line of the paste.
Sure I am not suggesting remove it, its is likely the right thing for pastes anywhere besides first on line, just that it isn't the right thing for whole lines with usual settings for offside languages, so that makes more choice and its not really a setting, it will vary from one paste to the next so we need multiple paste options:
Options 2 and 3 should be added to the menu by the language specific plugin that controls behaviour ... what? ... Nooooo!!! There is a reason nearly all other IDEs are built from plugins, not built-in 😁 |
Agree
Good point, nice dissection of the problem. I would go with a rather simplistic algo, that IMO covers a lot of cases without trying to be too smart:
In pseudo code:
Edit: fixed pseudo code algo |
Hi, let me start with an expression of gratitude for this great text editor!
This is a feature request:
Scenario steps:
Current behavior:
The first line of the text is pasted at the cursor location. (indented on level 2)
All the other lines of the clipboard contents are pasted at column 0 (indentation level 1).
Desired behavior:
Have all the lines of the pasted clipboard text be "padded" with the indentation level of the cursor.
e.g.
Thanks in advance!
Even if this doesn't get implemented, I'd love to hear why this is not a desired behavior :)
The text was updated successfully, but these errors were encountered: