diff --git a/lib/ruby_lsp/executor.rb b/lib/ruby_lsp/executor.rb index fb3181f1e..e5cc53013 100644 --- a/lib/ruby_lsp/executor.rb +++ b/lib/ruby_lsp/executor.rb @@ -204,8 +204,6 @@ def did_change_watched_files(changes) sig { void } def perform_initial_indexing - return unless @store.experimental_features - # The begin progress invocation happens during `initialize`, so that the notification is sent before we are # stuck indexing files RubyIndexer.configuration.load_config @@ -629,37 +627,35 @@ def initialize_request(options) ) end - if @store.experimental_features - # Dynamically registered capabilities - file_watching_caps = options.dig(:capabilities, :workspace, :didChangeWatchedFiles) - - # Not every client supports dynamic registration or file watching - if file_watching_caps&.dig(:dynamicRegistration) && file_watching_caps&.dig(:relativePatternSupport) - @message_queue << Request.new( - message: "client/registerCapability", - params: Interface::RegistrationParams.new( - registrations: [ - # Register watching Ruby files - Interface::Registration.new( - id: "workspace/didChangeWatchedFiles", - method: "workspace/didChangeWatchedFiles", - register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( - watchers: [ - Interface::FileSystemWatcher.new( - glob_pattern: "**/*.rb", - kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE, - ), - ], - ), + # Dynamically registered capabilities + file_watching_caps = options.dig(:capabilities, :workspace, :didChangeWatchedFiles) + + # Not every client supports dynamic registration or file watching + if file_watching_caps&.dig(:dynamicRegistration) && file_watching_caps&.dig(:relativePatternSupport) + @message_queue << Request.new( + message: "client/registerCapability", + params: Interface::RegistrationParams.new( + registrations: [ + # Register watching Ruby files + Interface::Registration.new( + id: "workspace/didChangeWatchedFiles", + method: "workspace/didChangeWatchedFiles", + register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new( + watchers: [ + Interface::FileSystemWatcher.new( + glob_pattern: "**/*.rb", + kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE, + ), + ], ), - ], - ), - ) - end - - begin_progress("indexing-progress", "Ruby LSP: indexing files") + ), + ], + ), + ) end + begin_progress("indexing-progress", "Ruby LSP: indexing files") + Interface::InitializeResult.new( capabilities: Interface::ServerCapabilities.new( text_document_sync: Interface::TextDocumentSyncOptions.new( diff --git a/test/executor_test.rb b/test/executor_test.rb index 550595de0..076abe6e0 100644 --- a/test/executor_test.rb +++ b/test/executor_test.rb @@ -109,14 +109,12 @@ def test_initialize_uses_utf_16_if_no_encodings_are_specified end def test_initialized_populates_index - @store.experimental_features = true @executor.execute({ method: "initialized", params: {} }) index = @executor.instance_variable_get(:@index) refute_empty(index.instance_variable_get(:@entries)) end def test_initialized_recovers_from_indexing_failures - @store.experimental_features = true RubyIndexer::Index.any_instance.expects(:index_all).once.raises(StandardError, "boom!") @executor.execute({ method: "initialized", params: {} }) @@ -204,6 +202,12 @@ def test_shows_error_if_formatter_set_to_rubocop_but_rubocop_not_available assert_equal("none", @store.formatter) refute_empty(@message_queue) + + # Account for starting and ending the progress notifications during initialized + assert_equal("window/workDoneProgress/create", @message_queue.pop.message) + assert_equal("$/progress", @message_queue.pop.message) + assert_equal("$/progress", @message_queue.pop.message) + notification = T.must(@message_queue.pop) assert_equal("window/showMessage", notification.message) assert_equal( diff --git a/test/integration_test.rb b/test/integration_test.rb index 52dc04feb..fbabc379d 100644 --- a/test/integration_test.rb +++ b/test/integration_test.rb @@ -372,11 +372,9 @@ def test_diagnostics end def test_workspace_symbol - initialize_lsp(["workspaceSymbol"], experimental_features_enabled: true) + initialize_lsp(["workspaceSymbol"]) open_file_with("class Foo\nend") # Read the response for the progress indicator notifications - read_response("window/workDoneProgress/create") - read_response("$/progress") read_response("textDocument/didOpen") # Populate the index @@ -455,6 +453,8 @@ def initialize_lsp(enabled_features, experimental_features_enabled: false) enabled_providers = enabled_features.map { |feature| FEATURE_TO_PROVIDER[feature] } assert_equal([:positionEncoding, :textDocumentSync, *enabled_providers], response[:capabilities].keys) + read_response("window/workDoneProgress/create") + read_response("$/progress") end def open_file_with(content) diff --git a/test/requests/definition_expectations_test.rb b/test/requests/definition_expectations_test.rb index 2b0cac57a..d29d67682 100644 --- a/test/requests/definition_expectations_test.rb +++ b/test/requests/definition_expectations_test.rb @@ -12,7 +12,6 @@ def run_expectations(source) position = @__params&.first || { character: 0, line: 0 } store = RubyLsp::Store.new - store.experimental_features = true store.set(uri: URI("file:///folder/fake.rb"), source: source, version: 1) executor = RubyLsp::Executor.new(store, message_queue) @@ -60,7 +59,6 @@ def test_jumping_to_default_gems uri = URI::Generic.from_path(path: path) store = RubyLsp::Store.new - store.experimental_features = true store.set(uri: URI("file:///folder/fake.rb"), source: <<~RUBY, version: 1) Pathname RUBY