LucHermitte / lh-brackets

LH's bracketing system for vim
Other
50 stars 2 forks source link

Line inserted above current line with typing '(' #1

Closed galou closed 9 years ago

galou commented 9 years ago

Hi,

thank you for providing this plugin.

I wanted to try it with a C++ file and here is what happens:

void
foo(|)«»

(| represent the cursor position).

How can I avoid this behavior and obtain

void foo(|)«»

?

Thanks for your help!

LucHermitte commented 9 years ago

Hello

Lately I've tried to fix an issue when the pair of brackets inserted (plus the placeholder) was expanded after the column equal to &textwidth.

Could it be that you are not typing just void foo, but something quite long and that the column of the cursor is within 4 columns to the one specified by &textwidth when you hit the ( key ? (In that case I can reproduce your problem)

galou commented 9 years ago

I'm afraid not. void foo was the only text present on the line. What can also be is an incompatibility with another plugin (I think of YouCompleteMe for example). My vim configuration is on http://github/galou/dotvim.git. I'll try to test without any other plugin.

LucHermitte commented 9 years ago

You can try to instrument autoload/lh/brackets.vim line 360. If I'm not mistaken, you enter this case. You can try to save the various local variables (line, open and close in g:globalvariables or to print them along with &tw to see how lh-brackets interprets your context.

galou commented 9 years ago

I tried without other plugins (except NeoBundle and lh-brackets dependencies). I had the same behavior. Interestingly, on my "minimal" installation, I had the line-insertion behavior also on Python files, whereas on my production configuration, no line break was inserted in the middle of the line on Python files. I'd be glad to help with testing but I have no idea how to do what you suggest (saving in g:globalvariables or printing).

LucHermitte commented 9 years ago

I think I know what went wrong.

I suspect that textwidth is 0 in your configuration ; which is a valid setting, but one I did not think about.

If you type :set tw?

vim answers 0, does it?

It should be fixed now.

galou commented 9 years ago

Bravo Luc !

Indeed, tw == 80 with Python and tw == 0 with C++, what explains the behavior.

Thank your your quick fix ! I just tested it positively.