Skip to content
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

Unexpected modifications when using gS / gJ #194

Open
Kawsay opened this issue Aug 31, 2022 · 1 comment
Open

Unexpected modifications when using gS / gJ #194

Kawsay opened this issue Aug 31, 2022 · 1 comment

Comments

@Kawsay
Copy link

Kawsay commented Aug 31, 2022

Vim version: 9.0
language: Ruby

With a line like:

foo = [ {a: 1, b: 2}, {c: 3, d: 4} ]

placing the cursor on the beginning of the array ([) then pressing gS gives me:

foo = [
  {a: 1, b: 2},
  c: 3,
  d: 4
]

when I'm expecting:

foo = [
  {a: 1, b: 2},
  {c: 3, d: 4}
]

Also, but I guess it's known and it's clearly and edge-case, joining modules with named as a single letter fails:

module A
  module B
  end
end

# cursor on A then gJ
module A module B
  end
end

Both modules need to be named with multiple letters in order to be successfully joined

module Aa
  module Bb
  end
end

# cursor on Aa then gJ
module Aa::Bb
end

# works like a charm, thanks for your wonderful plugin !
@Kawsay Kawsay changed the title Unexpected modifications when using gS Unexpected modifications when using gS / gJ Aug 31, 2022
@AndrewRadev
Copy link
Owner

AndrewRadev commented Sep 4, 2022

# works like a charm, thanks for your wonderful plugin !

Thank you kindly :)

I've pushed fixes to both issues. For the first one, it was something that worked as a side effect of arrays being essentially split like function calls -- syntactically, expanding the last hash like that is a thing that works and I've had issues and PRs related to this. But it seems I forgot to consider that it makes sense not to do it by default, so I've added a new option that enables it, ruby_expand_options_in_arrays, and your case should work correctly out of the box now.

The second issue just looks like an oversight on my part. I've tweaked the relevant regexes to allow a single capital variable to work as a module name. I don't see any issues in the tests, so I think it should be safe.

Let me know if both of these fixes work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants