Skip to content

Commit 8a30d2d

Browse files
committed
Skip directories for view paths
1 parent e7a4f68 commit 8a30d2d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/ruby_lsp/ruby_lsp_rails/code_lens.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ def add_jump_to_view(node)
199199
.downcase
200200

201201
view_uris = Dir.glob("#{@client.rails_root}/app/views/#{controller_name}/#{action_name}*").map! do |path|
202+
# it's possible we could have a directory with the same name as the action, so we need to skip those
203+
next if FileTest.directory?(path)
204+
202205
URI::Generic.from_path(path: path).to_s
203-
end
206+
end.compact
207+
204208
return if view_uris.empty?
205209

206210
@response_builder << create_code_lens(

test/dummy/app/views/users/index/.keep

Whitespace-only changes.

test/ruby_lsp_rails/code_lens_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def index
360360
view_lens = response[1]
361361

362362
assert_equal("Jump to view", view_lens.command.title)
363+
# NOTE: The `views/users` directory contains a directory named `index` which should not be returned.
363364
assert_equal(
364365
[[
365366
URI::Generic.from_path(path: "#{dummy_root}/app/views/users/index.html.erb").to_s,

0 commit comments

Comments
 (0)