cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

"break" action doesn't use correct indentation

Open pokey opened this issue 1 year ago • 3 comments

Our new "break" action for splitting lines doesn't properly indent, because it doesn't use the LSP. For example, in the following talonscript:

aaa: bbb

Saying "break bat" results in

aaa:
bbb

instead of the desired

aaa:
    bbb

We should prob implement this similar to how we implement "pour": just go to the spot, press enter, and move away. Though I'm not sure that's possible extension-side? Might need to do it from Talon.

And tbh it's not uncommon that I want to leave my cursor there anyway. I've gone back to my old implementation for now:

break <user.cursorless_target>:
    user.cursorless_command("setSelectionBefore", cursorless_target)
    user.vscode("hideSuggestWidget")
    key("enter")

pokey avatar Jan 29 '24 19:01 pokey

For pour we don't actually press enter from Talon. Vscode has a built in action to add a new line that we utilize. We could probably do the same thing here.

AndreasArvidsson avatar Feb 12 '24 16:02 AndreasArvidsson

No I don't think that would work because it doesn't break the line. I guess we could delete the tail, then run that action, then insert the tail on the new line?

Tho I think even that won't work because I believe if you press enter in the middle of parens it puts the closing paren on the line after the new line, dedented

pokey avatar Feb 14 '24 13:02 pokey

Something like that could work

AndreasArvidsson avatar Feb 15 '24 08:02 AndreasArvidsson