Multi cursor: Paste with single cursor causes uneven idents
Hi
Consider the following, where you mark and copy all cases of word with multiple cursors.
/*
something word
a word
abc word
*/
Go back to a single cursor and paste on an empty line inside a comment. You get this:
/*
word
word
word
*/
I would expect this (VS, VS Code, Notepad++ does this):
/*
word
word
word
*/
If you paste it outside of a comment, it gets even more jumbled if the lines does not end with ;. Likely due to the IDE auto ident on paste:
word
word
word
Maybe consider disabling/reduce auto indent on multi line paste? It's something that has been a bit odd without multi cursor as well.
Hiliting @kallisto56
I'll look into it.
This seems to be fixed in the latest nightly, thanks!
However after pasting, a single cursor becomes multi-cursor again. This is not aligned with other editors (Tested VS and VS Code).
Ah? No, that's not yet fixed. It's a bit of a rabbit hole, but I'll figure it out eventually. Just need to fix one more thing before I dig into it completly.
Copying with multiple cursors and then pasting with a single cursor creates secondary cursors by design. I personally find it useful pretty often. Maybe an option in settings for such behaviour would be more desirable. That's ofcourse if Beefy would like it.
If there's a way that the vast majority of other popular editors do it then that's how we should do it too, I think.
I'm not a huge fan of adding options unless there's a fairly good reason for it (ie: the "popular" way is only 80% popular so we still want to give the options for the other 20%, but I don't think that's the case here, right?)
Frankly, I actually prefer it the way it is. Other editors stay in single-line mode, and I actually found that annoying in many cases. That said, doing it differently than other editors may mess with one’s muscle memory a bit.
It's interesting how different we do things. I can't even think of an example where I find the current version a benefit.
Anyway. The reason why editors do this, is because there is no difference between having multiple lines from a single cursor or multiple lines from multiple cursors. It's just multiple lines. This has multiple benefits. It's also why it can't even choose how many cursors you end up with when pasting.
Beef currently has those as two distinct things. That made me think of another "bug".
Having these two lines:
abc
abc
Mark both lines with a single cursor and copy them. Now go to multi cursor at the end of both lines and paste. You get this:
abcabc
abc
abcabc
abc
I would expect this, which is also how VS and VS Code does it:
abcabc
abcabc
Another benefit of just treating it as lines is when you mix the amount of cursors used. You could potentially have two cursors copying two lines each, which is then pasted with 4 cursors. It just works in other editors, as it's always just lines.
@m910q Yeah, VS Code has a setting called “Multi Cursor Paste” which controls this. I actually think it’s very useful I would love to see it in the Beef IDE.
I'm leaning towards what Beefy suggested and just waiting for him to accept current pull-request so that I can make another one that removes feature that creates multi-cursors when pasting with a single cursor. I've already removed it on my end and indentation problem went back to how it was before multi-cursors.
I'm thinking this way: sometimes this feature is very handy, but, given that other editors do not do that, there is a chance to mess up source code without realizing it, which happened to me once so far (and I think that's already enough times).
There was an idea to color border of the SourceEditWidgetContent differently, when it has multiple cursors, so that it would be more noticable, although I have not tested it.