kana / vim-textobj-indent

Vim plugin: Text objects for indented blocks of lines
http://www.vim.org/scripts/script.php?script_id=2484
166 stars 10 forks source link

Visual ai is based on start of selection instead of cursor position #10

Open bew opened 2 years ago

bew commented 2 years ago

With the following code:

def foo():
    pass

@decorator               # visual select this line
def bar():               # and this line
    print("some code")   # and this line, cursor should be left on this line
    print("some other code")

    print("here we are doing real things!")
    print("some more other code...")

def other_foo():
    pass

So we're in visual mode, the cursor is on an indented line inside function bar.

Now if I do ai I'd expect to select the rest (or maybe only the inside?) of the function bar, instead it select the whole file..

It looks like it considers the start of the visual search as the indentation to use, but I think it should take the current cursor position for this, no?

NOTE: when we're in normal mode, and the cursor is on a print in function bar, vai does select only the inside of the function, so that works.

kana commented 2 years ago

Thank you for the feedback. I've never used ai / ii after selecting some area, so that I didn't notice that problem.

Your suggestion sounds reasonable. I'll consider changing ai / ii to extend the current selection based on the cursor line.