File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ def on_call_node_enter(node)
60
60
61
61
if Support ::Callbacks ::ALL . include? ( message )
62
62
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 )
65
65
end
66
66
end
67
67
@@ -90,7 +90,6 @@ def handle_callback(node)
90
90
def handle_route ( node )
91
91
result = @client . route_location ( node . message )
92
92
93
- # A token could match the _path or _url pattern, but not be an actual route.
94
93
location = T . must ( result ) . fetch ( :location )
95
94
return unless location
96
95
Original file line number Diff line number Diff line change 22
22
# NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the
23
23
# client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key.
24
24
25
- # ActionDispatch::Routing::Mapper.route_source_locations = true
26
-
27
25
module RubyLsp
28
26
module Rails
29
27
class Server
@@ -85,16 +83,9 @@ def execute(request, params)
85
83
86
84
sig { params ( name : String ) . returns ( T ::Hash [ Symbol , T . untyped ] ) }
87
85
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 ]
97
87
88
+ # A token could match the _path or _url pattern, but not be an actual route.
98
89
unless ::Rails . application . routes . named_routes . key? ( key )
99
90
return {
100
91
result : {
@@ -112,9 +103,10 @@ def route_location(name)
112
103
} ,
113
104
}
114
105
end
106
+
115
107
{
116
108
result : {
117
- location : ::Rails . root . to_s + "/" + route . source_location ,
109
+ location : ::Rails . root . join ( route . source_location ) ,
118
110
} ,
119
111
}
120
112
end
You can’t perform that action at this time.
0 commit comments