-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reload routes when changed #501
base: main
Are you sure you want to change the base?
Conversation
ff848d9
to
003e017
Compare
003e017
to
34356a2
Compare
30a8a50
to
8944ed6
Compare
private | ||
|
||
def response | ||
_headers, content = @stdout.string.split("\r\n\r\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to change to handle making multiple requests.
JSON.parse(content, symbolize_names: true) | ||
headers, content = @stdout.string.split("\r\n\r\n") | ||
content_length = headers[/Content-Length: (\d+)/i, 1].to_i | ||
# binding.break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vinistock I'm trying to figure out what's happening here: If I add the breakpoint, and call @stdout.string = ""
each time, it passes. But I call it from the code it fails with not opened for writing (IOError)
.
change[:uri].end_with?("db/schema.rb") || change[:uri].end_with?("structure.sql") | ||
end | ||
schema = lambda { |change| change[:uri].end_with?("db/schema.rb") || change[:uri].end_with?("structure.sql") } | ||
routes = lambda { |change| change[:uri].end_with?("routes.rb") || change[:uri].match?("routes/**/*.rb") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to simplify the conditional.
@@ -141,7 +144,7 @@ def register_additional_file_watchers(global_state:, outgoing_queue:) | |||
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( | |||
watchers: [ | |||
Interface::FileSystemWatcher.new( | |||
glob_pattern: "**/*structure.sql", | |||
glob_pattern: "**/*structure.sql,**/*routes.rb,routes/**/*.rb", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should cover almost any way that people set up the Rails routes, but there is a risk of a false positive if someone is using the term routes
for something else in their app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 but I wonder if we can ask Rails where all the routes files are...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly:
dummy(dev)> Rails.application.routes.draw_paths.map(&:to_s)
=>
["/Users/andyw8/.gem/ruby/3.3.0/gems/actionview-8.0.0.beta1/config/routes",
"/Users/andyw8/.gem/ruby/3.3.0/gems/activestorage-8.0.0.beta1/config/routes",
"/Users/andyw8/.gem/ruby/3.3.0/gems/actioncable-8.0.0.beta1/config/routes",
"/Users/andyw8/.gem/ruby/3.3.0/gems/actionmailbox-8.0.0.beta1/config/routes",
"/Users/andyw8/.gem/ruby/3.3.0/gems/actiontext-8.0.0.beta1/config/routes",
"/Users/andyw8/src/github.com/Shopify/ruby-lsp-rails/test/dummy/config/routes",
"/Users/andyw8/src/github.com/Shopify/ruby-lsp-rails/test/dummy/config/routes"]
No description provided.