Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the same as #4804, but I moved it over to it's own branch instead of master. Use this one.
Copied from #4804:
I took the time to fix #4796.
Previous code logic:
It seems like #765 actually only addressed part of the problem. @marceloramires checked to see if the first range in the list was a selection and assumed that if this was a selection, the others would be selections too. If this was the case, then delete all the text in the selections. This handled deleting multicursor selections.
There was then separate logic that handled the tabbing. This logic was only built to accommodate one cursor, so if it detects a tab, it deletes it, and if it doesn't, it uses the function deleteH(-1, "char"), which handles the situation like a normal deletion. Normal deletion worked as expected for multicursor, but the tab deletion was only built considering one cursor and specifically deletes the tab for the "primary" cursor, which is the one returned by cm.getCursor().
Updated code logic:
To fix this, I consider each cursor separately. For each cursor, I first check if it is a selection. If it is, I delete the selection. Then I know it's a cursor, so I check to see that all characters on the line that come before it are spaces. If they're all spaces, we use tab delete, otherwise, we only delete one character at a time.
Note on new logic:
I also want to note that deleting one character at a time is somewhat different from the previous logic. Before, even if there was text on the line, it would still use tab logic, so if I have
stuff = 'tabs | '
012301230123012301230123
this is what backspacing would do
stuff = 'tabs | '
012301230123012301230123
Now, it just deletes one character, which is what I found PyCharm did, and what I think logically makes sense. If you have spaces after the initial text, they're no longer used for indentation, and you're more likely to care about the specific number of spaces (which deleting would make unclear). If anything, I can put tab deletion back in, but I think it should consistently be 4 spaces rather than to the nearest tabstop, which would seem random unless you're counting all the characters in the line each time you hit delete.
If all this looks good, I'm ready to merge!