Skip to content

Commit c552c44

Browse files
committed
wip
1 parent 86d613b commit c552c44

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

lib/ruby_lsp/ruby_lsp_rails/definition.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def on_call_node_enter(node)
6060

6161
if Support::Callbacks::ALL.include?(message)
6262
handle_callback(node)
63-
elsif message.match?(/^([a-z0-9_]+)(_path|_url)$/)
64-
handle_route(node) # check. what about digits?
63+
elsif message.match?(/^([a-zA-Z0-9_]+)(_path|_url)$/)
64+
handle_route(node)
6565
end
6666
end
6767

@@ -90,7 +90,6 @@ def handle_callback(node)
9090
def handle_route(node)
9191
result = @client.route_location(node.message)
9292

93-
# A token could match the _path or _url pattern, but not be an actual route.
9493
location = T.must(result).fetch(:location)
9594
return unless location
9695

lib/ruby_lsp/ruby_lsp_rails/server.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
# NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the
2323
# client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key.
2424

25-
# ActionDispatch::Routing::Mapper.route_source_locations = true
26-
2725
module RubyLsp
2826
module Rails
2927
class Server
@@ -85,16 +83,9 @@ def execute(request, params)
8583

8684
sig { params(name: String).returns(T::Hash[Symbol, T.untyped]) }
8785
def route_location(name)
88-
unless ActionDispatch::Routing::Mapper.route_source_locations
89-
return {
90-
result: {
91-
location: nil,
92-
},
93-
}
94-
end
95-
96-
key = name.match(/^([a-z_]+)(_path|_url)$/)[1]
86+
key = name.match(/^([a-zA-Z0-9_]+)(_path|_url)$/)[1]
9787

88+
# A token could match the _path or _url pattern, but not be an actual route.
9889
unless ::Rails.application.routes.named_routes.key?(key)
9990
return {
10091
result: {
@@ -112,9 +103,10 @@ def route_location(name)
112103
},
113104
}
114105
end
106+
115107
{
116108
result: {
117-
location: ::Rails.root.to_s + "/" + route.source_location,
109+
location: ::Rails.root.join(route.source_location),
118110
},
119111
}
120112
end

0 commit comments

Comments
 (0)