-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vim: gS on dict access dot incorrectly adds space #207
Comments
Should avoid problem in #207, but should it be the default?
That's a good point. I've pushed a new setting, called let g:splitjoin_vim_split_whitespace_after_backslash = 0 This will consistently not add a space when breaking lines. I think that's the right way to go -- I could check for a Additionally, how do you feel about this not being the default? I think it would be a safer default, but it would change behaviour for (the admittedly few) people already using it, and I'd rather avoid this kind of surprise. |
I'm not sure how I feel about the default here, but I collected some data. According to ripgrep, 108 It's also worth noting that not adding a space may result in surprising semantics as well. IIUC, the vim code ca
\ll Foo('he
\lo world') is equivalent to call
\Foo('hello
\world') becomes |
That's a fair point. I'm starting to think a preference is not the way to go, but simply whether there is or isn't whitespace at or before the cursor when breaking the line. In your examples, if you broke the If you consistently use it to break method calls, they'll all consistently have no whitespace. If you break dictionaries (my main use case), and you have I've pushed a change that implements that and should handle your examples sensibly. Could you try it out and let me know how it feels? If we don't find any issues with the scheme, I'll remove the setting I introduced and just leave this smarter handling. |
Given the vimscript code
l:my_dict.my_key
, using splitjoin'sgS
at the.
character producesWhen vim's
scriptversion
is1
this creates ambiguity between dict key lookup and string concatenation due to the space between\
and.my_key
. (The dot is an attractive split point when writing vim script with an object-oriented style:l:object.SomeMethod(arg, list).AnotherMethod(more, args)
.)Vim seems to gracefully handle the
\ .my_key
ambiguity by checking if the type ofl:my_dict
is Dict, but NeoVim produces anE731: using Dictionary as a String
error.:help expr-entry
says "There must not be white space before or after the dot." It would be nice if splitting on a dot without space around it would result in a semantically identical split like(note the lack of space in
\.
).The text was updated successfully, but these errors were encountered: