tidalcycles / vim-tidal

Vim plugin for TidalCycles
MIT License
223 stars 56 forks source link

Fix to multi-line launch #4

Closed kbdnr closed 9 years ago

kbdnr commented 9 years ago

Fix to method call for multi-line getpos execution.

munshkr commented 9 years ago

Hey @kbdnr, thanks for the PR! I don't understand what it fixes though... does Vim throws an error when calling getcurpos()? From the docs, I can see getpos('.') is the same, except that it doesn't store the prefered column:

getcurpos()        Get the position of the cursor.  This is like getpos('.'), but
                   includes an extra item in the list:
                       [bufnum, lnum, col, off, curswant]
                   The "curswant" number is the preferred column when moving the
                   cursor vertically.
                   This can be used to save and restore the cursor position:
                           let save_cursor = getcurpos()
                           MoveTheCursorAround
                           call setpos('.', save_cursor)
kbdnr commented 9 years ago

Yes for me vim is throwing an error.

I can elaborate and provide a screenshot if you would like to see the previous errors i had encountered. Additionally, i don't see the purpose of the unnecessary overhead involved in the previous implementation where regardless, the blocks are selected by essentially inspecting the surrounding (or lack of) whitespace. Great implementation otherwise

munshkr commented 9 years ago

I can elaborate and provide a screenshot if you would like to see the previous errors i had encountered.

Yes, that'd be great!

Additionally, i don't see the purpose of the unnecessary overhead involved in the previous implementation where regardless, the blocks are selected by essentially inspecting the surrounding (or lack of) whitespace. Great implementation

Do you mean storing/restoring the cursor position? Or just using getcurpos()? If it's the former, I'd say a disagree, as I think it's really useful to keep the cursor in the same place after executing. It allows you to, for example, play and try different values of a parameter or something in the middle of a line very quickly. If you meant the use of that function, getpos('.') is still a good alternative, although I'd like to know first if the error you're having can be fixed.

kbdnr commented 9 years ago

https://i.imgur.com/9tT5Imu.png

additionally with my fix you do not lose the cursor position, so I disagree with your logic on that.

munshkr commented 9 years ago

Apparently, getcurpos was added on version 7.4.313 (!) I'll merge this and try to add a check and use getcurpos only if it's available.

Thanks!