@@ -970,35 +970,34 @@ defmodule NextLS do
970
970
{ :noreply , assign ( lsp , elixir_bin_path: elixir_bin_path ) }
971
971
end
972
972
973
- def handle_notification ( % TextDocumentDidSave { } , % { assigns: % { ready: false } } = lsp ) do
974
- { :noreply , lsp }
975
- end
976
-
977
973
# TODO: add some test cases for saving files in multiple workspaces
978
974
def handle_notification (
979
975
% TextDocumentDidSave {
980
976
params: % GenLSP.Structures.DidSaveTextDocumentParams { text: text , text_document: % { uri: uri } }
981
977
} ,
982
- % { assigns: % { ready: true } } = lsp
978
+ lsp
983
979
) do
984
- for task <- Task.Supervisor . children ( lsp . assigns . task_supervisor ) do
985
- Process . exit ( task , :kill )
986
- end
987
-
988
980
refresh_refs =
989
- dispatch ( lsp . assigns . registry , :runtimes , fn entries ->
990
- for { pid , % { name: name , uri: wuri } } <- entries ,
991
- String . starts_with? ( uri , wuri ) ,
992
- into: % { } do
993
- token = Progress . token ( )
994
- Progress . start ( lsp , token , "Compiling #{ name } ..." )
981
+ if lsp . assigns . ready do
982
+ for task <- Task.Supervisor . children ( lsp . assigns . task_supervisor ) do
983
+ Process . exit ( task , :kill )
984
+ end
995
985
996
- ref = make_ref ( )
997
- Runtime . compile ( pid , caller_ref: ref )
986
+ # dispatching to all workspaces
987
+ dispatch ( lsp . assigns . registry , :runtimes , fn entries ->
988
+ for { pid , % { name: name , uri: wuri } } <- entries ,
989
+ String . starts_with? ( uri , wuri ) ,
990
+ into: % { } do
991
+ token = Progress . token ( )
992
+ Progress . start ( lsp , token , "Compiling #{ name } ..." )
998
993
999
- { ref , { token , "Compiled #{ name } !" } }
1000
- end
1001
- end )
994
+ ref = make_ref ( )
995
+ Runtime . compile ( pid , caller_ref: ref )
996
+
997
+ { ref , { token , "Compiled #{ name } !" } }
998
+ end
999
+ end )
1000
+ end
1002
1001
1003
1002
lsp =
1004
1003
lsp
@@ -1008,16 +1007,14 @@ defmodule NextLS do
1008
1007
{ :noreply , lsp }
1009
1008
end
1010
1009
1011
- def handle_notification ( % TextDocumentDidChange { } , % { assigns: % { ready: false } } = lsp ) do
1012
- { :noreply , lsp }
1013
- end
1014
-
1015
1010
def handle_notification (
1016
1011
% TextDocumentDidChange { params: % { text_document: % { uri: uri } , content_changes: [ % { text: text } ] } } ,
1017
1012
lsp
1018
1013
) do
1019
- for task <- Task.Supervisor . children ( lsp . assigns . task_supervisor ) do
1020
- Process . exit ( task , :kill )
1014
+ if lsp . assigns . ready do
1015
+ for task <- Task.Supervisor . children ( lsp . assigns . task_supervisor ) do
1016
+ Process . exit ( task , :kill )
1017
+ end
1021
1018
end
1022
1019
1023
1020
lsp = put_in ( lsp . assigns . documents [ uri ] , String . split ( text , "\n " ) )
0 commit comments