Skip to content

Error processing textDocument/didChange: undefined method '[]' for nil (range) #3148

Closed as not planned
@pusewicz

Description

@pusewicz

Description

The edits pushed to the LSP server are hashes that contain only the text key, eg:

[{text: "..."}]

Reproduction steps

  1. Start the Ruby LSP using MacVim and LSP plugin
  2. Open a Ruby file
  3. Type something to get the autocompletion kick-in
  4. See unexpected behavior

Code snippet or error message

02/07/25 10:24:48: [Log]: Error processing textDocument/didChange: /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/document.rb:104:in 'block in RubyLsp::Document#push_edits': undefined method '[]' for nil (NoMethodError)

        start_position = scanner.find_char_position(range[:start])
                                                         ^^^^^^^^
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/document.rb:100:in 'Array#each'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/document.rb:100:in 'RubyLsp::Document#push_edits'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/store.rb:80:in 'RubyLsp::Store#push_edits'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/server.rb:428:in 'block in RubyLsp::Server#text_document_did_change'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/global_state.rb:64:in 'Thread::Mutex#synchronize'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/global_state.rb:64:in 'RubyLsp::GlobalState#synchronize'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/server.rb:427:in 'RubyLsp::Server#text_document_did_change'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/server.rb:27:in 'RubyLsp::Server#process_message'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/base_server.rb:94:in 'block in RubyLsp::BaseServer#start'
	from /Users/piotr/.gem/ruby/3.4.1/gems/language_server-protocol-3.17.0.4/lib/language_server/protocol/transport/io/reader.rb:20:in 'LanguageServer::Protocol::Transport::Io::Reader#read'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/lib/ruby_lsp/base_server.rb:46:in 'RubyLsp::BaseServer#start'
	from /Users/piotr/.gem/ruby/3.4.1/gems/ruby-lsp-0.23.9/exe/ruby-lsp:154:in '<top (required)>'
	from /Users/piotr/.gem/ruby/3.4.1/bin/ruby-lsp:25:in 'Kernel#load'
	from /Users/piotr/.gem/ruby/3.4.1/bin/ruby-lsp:25:in '<top (required)>'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli/exec.rb:59:in 'Kernel.load'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli/exec.rb:59:in 'Bundler::CLI::Exec#kernel_load'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli.rb:452:in 'Bundler::CLI#exec'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/exe/bundle:28:in 'block in <top (required)>'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/lib/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
	from /Users/piotr/.gem/ruby/3.4.1/gems/bundler-2.6.2/exe/bundle:20:in '<top (required)>'
	from /Users/piotr/.rubies/ruby-3.4.1/bin/bundle:25:in 'Kernel#load'
	from /Users/piotr/.rubies/ruby-3.4.1/bin/bundle:25:in '<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp-wantedExtra attention is needednon-vscode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions