This repository was archived by the owner on Oct 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +70
-2
lines changed Expand file tree Collapse file tree 2 files changed +70
-2
lines changed Original file line number Diff line number Diff line change @@ -104,9 +104,17 @@ defmodule NextLS do
104104 } , assign ( lsp , root_uri: root_uri ) }
105105 end
106106
107- def handle_request ( % WorkspaceSymbol { params: % { query: _query } } , lsp ) do
107+ def handle_request ( % WorkspaceSymbol { params: % { query: query } } , lsp ) do
108+ filter = fn sym ->
109+ if query == "" do
110+ true
111+ else
112+ to_string ( sym ) =~ query
113+ end
114+ end
115+
108116 symbols =
109- for % SymbolTable.Symbol { } = symbol <- SymbolTable . symbols ( lsp . assigns . symbol_table ) do
117+ for % SymbolTable.Symbol { } = symbol <- SymbolTable . symbols ( lsp . assigns . symbol_table ) , filter . ( symbol . name ) do
110118 % SymbolInformation {
111119 name: to_string ( symbol . name ) ,
112120 kind: elixir_kind_to_lsp_kind ( symbol . type ) ,
Original file line number Diff line number Diff line change @@ -399,4 +399,64 @@ defmodule NextLSTest do
399399 "name" => "Foo.CodeAction.NestedMod"
400400 } in symbols
401401 end
402+
403+ test "workspace symbols with query" , % { client: client , cwd: cwd } do
404+ assert :ok ==
405+ notify ( client , % {
406+ method: "initialized" ,
407+ jsonrpc: "2.0" ,
408+ params: % { }
409+ } )
410+
411+ assert_notification "window/logMessage" , % { "message" => "[NextLS] Runtime ready..." }
412+ assert_notification "window/logMessage" , % { "message" => "[NextLS] Compiled!" }
413+
414+ request client , % {
415+ method: "workspace/symbol" ,
416+ id: 2 ,
417+ jsonrpc: "2.0" ,
418+ params: % {
419+ query: "fo"
420+ }
421+ }
422+
423+ assert_result 2 , symbols
424+
425+ assert [
426+ % {
427+ "kind" => 12 ,
428+ "location" => % {
429+ "range" => % {
430+ "start" => % {
431+ "line" => 3 ,
432+ "character" => 0
433+ } ,
434+ "end" => % {
435+ "line" => 3 ,
436+ "character" => 0
437+ }
438+ } ,
439+ "uri" => "file://#{ cwd } /lib/bar.ex"
440+ } ,
441+ "name" => "foo"
442+ } ,
443+ % {
444+ "kind" => 12 ,
445+ "location" => % {
446+ "range" => % {
447+ "start" => % {
448+ "line" => 4 ,
449+ "character" => 0
450+ } ,
451+ "end" => % {
452+ "line" => 4 ,
453+ "character" => 0
454+ }
455+ } ,
456+ "uri" => "file://#{ cwd } /lib/code_action.ex"
457+ } ,
458+ "name" => "foo"
459+ }
460+ ] == symbols
461+ end
402462end
You can’t perform that action at this time.
0 commit comments