From 2277709fc53c2a1ec0a64ca968aa532fcf38e1be Mon Sep 17 00:00:00 2001 From: _rogan <54429875+rogancodes@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:52:46 +0530 Subject: [PATCH] Ignore, if given path is directory while referencing and renaming (#2716) while fetching references and renaming, ignore if given path is a directory --- lib/ruby_lsp/requests/references.rb | 2 ++ lib/ruby_lsp/requests/rename.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/ruby_lsp/requests/references.rb b/lib/ruby_lsp/requests/references.rb index a3c626ad9..bd7694f37 100644 --- a/lib/ruby_lsp/requests/references.rb +++ b/lib/ruby_lsp/requests/references.rb @@ -78,6 +78,8 @@ def perform parse_result = Prism.parse_file(path) collect_references(reference_target, parse_result, uri) + rescue Errno::EISDIR, Errno::ENOENT + # If `path` is a directory, just ignore it and continue. If the file doesn't exist, then we also ignore it. end @store.each do |_uri, document| diff --git a/lib/ruby_lsp/requests/rename.rb b/lib/ruby_lsp/requests/rename.rb index 2b92e7402..0d6dd2b2d 100644 --- a/lib/ruby_lsp/requests/rename.rb +++ b/lib/ruby_lsp/requests/rename.rb @@ -147,6 +147,8 @@ def collect_text_edits(target, name) parse_result = Prism.parse_file(path) edits = collect_changes(target, parse_result, name, uri) changes[uri.to_s] = edits unless edits.empty? + rescue Errno::EISDIR, Errno::ENOENT + # If `path` is a directory, just ignore it and continue. If the file doesn't exist, then we also ignore it. end @store.each do |uri, document|