Skip to content

Commit

Permalink
Ignore, if given path is directory while referencing and renaming (#2716
Browse files Browse the repository at this point in the history
)

while fetching references and renaming, ignore if given path is a directory
  • Loading branch information
rogancodes authored Oct 15, 2024
1 parent c82ec13 commit 2277709
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ruby_lsp/requests/references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_lsp/requests/rename.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down

0 comments on commit 2277709

Please sign in to comment.