mjbrownie / swapit

vim plugin: Extensible Keyword Swapper
39 stars 8 forks source link

Bug when used before some HTML attributes #24

Open digital-carver opened 9 years ago

digital-carver commented 9 years ago

Eg. with a line like <div class="wrapper2">, with the cursor at the space between div and class, pressing Ctrl-a turns it into <divhrefclass="wrapper">.

And with <input type="checkbox" name="foo" id="bar1">, if the cursor is on the double quotes after foo, the line turns into <input type="checkbox" name="fooclass id="bar">.

I'm a relatively new user and so don't know what swapit does in cases like this - i.e., when the cursor is at a non-swappable point - in other (non-HTML) contexts. I would prefer it if the plugin was activated only when the cursor is directly above a keyword, and the original Vim behaviour (of incrementing the next number) being maintained otherwise, but in any case the above behaviour is obviously never desirable.

mjbrownie commented 9 years ago

Thanks it seems to be more general than that.

eg. with "|" as the cursor

  foo   |                                                yes

will trigger the same effect. I'm not sure if this bug has always been there or it is a case of vim recently redefining what is in the "" register. This plugin is getting old now.

you can see the case with the above line by going :

At any rate it would be possible to check to see if the current cursor character is whitespace and trigger a 'w' event.

digital-carver commented 9 years ago

At any rate it would be possible to check to see if the current cursor character is whitespace and trigger a 'w' event.

It also happens when the cursor is on a double-quote (the name="foo" id="bar1" example above), so I guess the check has to be whether the cursor is on any non-word character? It appears SwapLists can only be made for strings with \w characters anyway, so that should be a safe enough check.