solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Renaming not working for functions ending with question mark or equals sign

Open schaerl opened this issue 5 months ago • 2 comments

Environment

  • Pop!_OS 22.04 LTS
  • Ruby 3.4.5 (via rbenv)
  • Solargraph 0.56.2
  • VsCode 1.103.1
  • NeoVim v0.11.3

Description I cannot rename functions that end with either = or ?. It doesn't work in VSCode or NeoVim with vim.lsp.

In the example below, I can rename the foo method, having the cursor either on the definition or at the call site. This also works with and without parentheses. For the is_bar? method, I can start renaming on definition or callsite, however, the initial renaming input is the name of the method without the question mark (is_bar), and after confirming a new name, that new name is only applied to the call site, only including a question mark if it was part of the new name For the baz= method, it doesn't work at all if I rename at the definiton. If I rename at the call site, the new name is applied to the callsite, even removing the space and the equals sign.

Expectation Renaming also works with those methods, i.e. definition and call sites are updated, and equals and question mark are part of the initial name.

Minimal code

class TestClass
  # works
  def foo(string)
  end

  # Don't work
  def is_bar?
  end
  def baz=(new_baz)
  end
end

TestClass.new.foo 'bar'

TestClass.new.is_bar?

TestClass.new.baz = 'baz'

schaerl avatar Aug 19 '25 10:08 schaerl

Issues I'm seeing (lsp-mode in emacs if it matters):

  1. Library#references_from calls Library#definitions_at with loc.range.ending.line, loc.range.ending.character.
  2. If you hover one character past def is_bar? it does not display the documentation.
  3. If you hover one character past def bing (not in example above) it displays documentation
  4. If you hover over any part of def baz=(new_baz), no documentation is shown.

apiology avatar Sep 10 '25 17:09 apiology

Same behavior as with ? happens for methods ending in !

fmorroni avatar Oct 15 '25 19:10 fmorroni