From d7f92865be5ecda4f976ca89bfbeb673c4dea6f8 Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:56:32 -0400 Subject: [PATCH] wip --- lib/ruby_lsp/ruby_lsp_rails/server.rb | 20 ++++++-------------- test/ruby_lsp_rails/server_test.rb | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/ruby_lsp/ruby_lsp_rails/server.rb b/lib/ruby_lsp/ruby_lsp_rails/server.rb index 593af2ed..3728b042 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/server.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/server.rb @@ -3,19 +3,12 @@ require "json" -# module ActionDispatch -# class MyRailtie < Rails::Railtie # :nodoc: -# initializer "my_railtie.configure", after: "action_dispatch.configure" do -# ActionDispatch::Routing::Mapper.route_source_locations = true -# end -# end -# end +ActionDispatch::Routing::Mapper.route_source_locations = true +Rails.application.routes.routes # NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the # client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key. -# TODO: this helps but it still failing intermittently. Trying to understand what's going on. - module RubyLsp module Rails module Common @@ -168,7 +161,7 @@ def resolve_route_info(requirements) { result: body } else - { result: "SL NIL" } + { result: nil } end end @@ -195,10 +188,9 @@ def route_location(name) { error: e.full_message(highlight: false) } end else - raise "NOT ENABLED" - # def route_location(name) - # { result: 444 } - # end + def route_location(name) + { result: nil } + end end def resolve_database_info_from_model(model_name) diff --git a/test/ruby_lsp_rails/server_test.rb b/test/ruby_lsp_rails/server_test.rb index 3a4da40a..fb748262 100644 --- a/test/ruby_lsp_rails/server_test.rb +++ b/test/ruby_lsp_rails/server_test.rb @@ -117,7 +117,7 @@ def <(other) @server.execute("route_location", { name: "user_path" }) puts response.inspect location = response[:result][:location] - assert_match %r{test/dummy/config/routes.rb:4$}, location + assert_match %r{test/dummy/config/routes.rb:3$}, location end test "route location returns nil for invalid routes" do