diff --git a/lib/ruby_lsp/executor.rb b/lib/ruby_lsp/executor.rb index a388788cf7..52db7ab625 100644 --- a/lib/ruby_lsp/executor.rb +++ b/lib/ruby_lsp/executor.rb @@ -188,14 +188,17 @@ def did_change_watched_files(changes) file_path = uri.to_standardized_path next if file_path.nil? || File.directory?(file_path) + base_path = $LOAD_PATH.find { |load_path| file_path.start_with?(load_path) } + indexable = RubyIndexer::Indexable.new(base_path, file_path) + case change[:type] when Constant::FileChangeType::CREATED - @index.index_single(file_path) + @index.index_single(indexable) when Constant::FileChangeType::CHANGED - @index.delete(file_path) - @index.index_single(file_path) + @index.delete(indexable) + @index.index_single(indexable) when Constant::FileChangeType::DELETED - @index.delete(file_path) + @index.delete(indexable) end end