AndrewRadev / sideways.vim

A Vim plugin to move function arguments (and other delimited-by-something items) left and right.
http://www.vim.org/scripts/script.php?script_id=4171
MIT License
481 stars 9 forks source link

Does not work correctly in typescript #54

Closed mphe closed 1 year ago

mphe commented 1 year ago

Shifting does not work correctly in typescript when types are specified.

This works fine:

function foo(a, b, c) {
    console.log(a, b)
}

This doesn't:

function foo(a: number, b: number, c: number) {
    console.log(a, b)
}

Using :SidewaysRight or :SidewaysLeft on the first argument 'a' works as expected. Using :SidewaysRight or :SidewaysLeft on any other argument, does not shift anything, but always places the cursor to the next type definition to the left.

E.g.: Cursor is on 'b' + :SidewaysRight => Nothing is shifted, cursor shifts to 'number' after 'a'.

AndrewRadev commented 1 year ago

Hmm, it was getting confused with interface Foo { value: A | B | C }. I've added some logic to make that case more specific. Honestly, I feel like maybe it's pointless to bother with this definition, I haven't really made much use of it. Maybe I'll remove it at some point altogether.

Seems like your example works for me now -- could you try it out as well?

mphe commented 1 year ago

That seems to work. Thanks for the quick fix and the great plugin!