cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Don't use final line indentation for move after

Open pokey opened this issue 2 years ago • 7 comments

When determining how to indent an inserted target for "pour" or "move after", we look at the final line of the target that is being poured or inserted after. This results in "move funk air after bat" in python having the first line of the new function indented. For example:

def foo():
    pass

    def foo():
    pass

We should instead use either the first line of the target or the line with minimum indentation to determine desired indentation for new target

pokey avatar Jul 05 '22 17:07 pokey

@AndreasArvidsson any opinion on whether to use first line or line with minimum indentation (or something else)?

pokey avatar Jul 05 '22 18:07 pokey

But if you had moved a single line you probably want this behavior. Maybe we have to do different behavior per scope type? Or maybe treat multiple line targets differently?

AndreasArvidsson avatar Jul 05 '22 18:07 AndreasArvidsson

I wouldn't want it for "move after funk", because in Python if the indentation is the same, it is not after the funk; it's inside of it. I could see doing that for "move after line"

pokey avatar Jul 05 '22 18:07 pokey

Exactly. Maybe if the insertion delimiter is multiple lines we take the minimum indentation but if it's a single line we take the previous line?

AndreasArvidsson avatar Jul 05 '22 18:07 AndreasArvidsson

Exactly. Maybe if the insertion delimiter is multiple lines we take the minimum indentation but if it's a single line we take the previous line?

What do you mean by the "previous line"? Why not just take the line containing the target itself if it is on a single line?

Also, when you say "insertion delimiter", do you mean "target"?

pokey avatar Jul 06 '22 13:07 pokey

That previous line in relation to the new insertion. ie the last line of the destination target.

No I mean the insertion delimiter. \n vs \n\n

Maybe taking the minimum character is the best way to go. When moving after a line you will get the same indentation as that line, but if you move after a paragraph or function you will get the same indentation as that entire thing.

AndreasArvidsson avatar Jul 06 '22 15:07 AndreasArvidsson

Yeah that seems like the easiest / most likely to be what you want in most cases

pokey avatar Jul 06 '22 15:07 pokey