@@ -937,6 +937,15 @@ def on_post_start(cls, window: sublime.Window, initiating_view: sublime.View,
937
937
"""
938
938
pass
939
939
940
+ @classmethod
941
+ def should_ignore (cls , view : sublime .View ) -> bool :
942
+ """
943
+ Exclude a view from being handled by the language server, even if it matches the URI scheme(s) and selector from
944
+ the configuration. This can be used to, for example, ignore certain file patterns which are listed in a
945
+ configuration file (e.g. .gitignore).
946
+ """
947
+ return False
948
+
940
949
@classmethod
941
950
def markdown_language_id_to_st_syntax_map (cls ) -> Optional [MarkdownLangMap ]:
942
951
"""
@@ -1383,6 +1392,9 @@ def compare_by_string(sb: Optional[SessionBufferProtocol]) -> bool:
1383
1392
def can_handle (self , view : sublime .View , scheme : str , capability : Optional [str ], inside_workspace : bool ) -> bool :
1384
1393
if not self .state == ClientStates .READY :
1385
1394
return False
1395
+ if self ._plugin and self ._plugin .should_ignore (view ):
1396
+ debug (view , "ignored by plugin" , self ._plugin .__class__ .__name__ )
1397
+ return False
1386
1398
if scheme == "file" :
1387
1399
file_name = view .file_name ()
1388
1400
if not file_name :
@@ -1759,8 +1771,7 @@ def _apply_code_action_async(
1759
1771
arguments = command .get ("arguments" )
1760
1772
if arguments is not None :
1761
1773
execute_command ['arguments' ] = arguments
1762
- return promise .then (
1763
- lambda _ : self .execute_command (execute_command , progress = False , view = view ))
1774
+ return promise .then (lambda _ : self .execute_command (execute_command , progress = False , view = view ))
1764
1775
return promise
1765
1776
1766
1777
def apply_workspace_edit_async (self , edit : WorkspaceEdit ) -> Promise [None ]:
@@ -1771,12 +1782,16 @@ def apply_workspace_edit_async(self, edit: WorkspaceEdit) -> Promise[None]:
1771
1782
return self .apply_parsed_workspace_edits (parse_workspace_edit (edit ))
1772
1783
1773
1784
def apply_parsed_workspace_edits (self , changes : WorkspaceChanges ) -> Promise [None ]:
1785
+ active_sheet = self .window .active_sheet ()
1786
+ selected_sheets = self .window .selected_sheets ()
1774
1787
promises = [] # type: List[Promise[None]]
1775
1788
for uri , (edits , view_version ) in changes .items ():
1776
1789
promises .append (
1777
1790
self .open_uri_async (uri ).then (functools .partial (self ._apply_text_edits , edits , view_version , uri ))
1778
1791
)
1779
- return Promise .all (promises ).then (lambda _ : None )
1792
+ return Promise .all (promises ) \
1793
+ .then (lambda _ : self ._set_selected_sheets (selected_sheets )) \
1794
+ .then (lambda _ : self ._set_focused_sheet (active_sheet ))
1780
1795
1781
1796
def _apply_text_edits (
1782
1797
self , edits : List [TextEdit ], view_version : Optional [int ], uri : str , view : Optional [sublime .View ]
@@ -1786,6 +1801,14 @@ def _apply_text_edits(
1786
1801
return
1787
1802
apply_text_edits (view , edits , required_view_version = view_version )
1788
1803
1804
+ def _set_selected_sheets (self , sheets : List [sublime .Sheet ]) -> None :
1805
+ if len (sheets ) > 1 and len (self .window .selected_sheets ()) != len (sheets ):
1806
+ self .window .select_sheets (sheets )
1807
+
1808
+ def _set_focused_sheet (self , sheet : Optional [sublime .Sheet ]) -> None :
1809
+ if sheet and sheet != self .window .active_sheet ():
1810
+ self .window .focus_sheet (sheet )
1811
+
1789
1812
def decode_semantic_token (
1790
1813
self , token_type_encoded : int , token_modifiers_encoded : int ) -> Tuple [str , List [str ], Optional [str ]]:
1791
1814
types_legend = tuple (cast (List [str ], self .get_capability ('semanticTokensProvider.legend.tokenTypes' )))
@@ -1914,8 +1937,8 @@ def m_workspace_configuration(self, params: Dict[str, Any], request_id: Any) ->
1914
1937
1915
1938
def m_workspace_applyEdit (self , params : Any , request_id : Any ) -> None :
1916
1939
"""handles the workspace/applyEdit request"""
1917
- self .apply_workspace_edit_async (params .get ('edit' , {})). then (
1918
- lambda _ : self .send_response (Response (request_id , {"applied" : True })))
1940
+ self .apply_workspace_edit_async (params .get ('edit' , {})) \
1941
+ . then ( lambda _ : self .send_response (Response (request_id , {"applied" : True })))
1919
1942
1920
1943
def m_workspace_codeLens_refresh (self , _ : Any , request_id : Any ) -> None :
1921
1944
"""handles the workspace/codeLens/refresh request"""
0 commit comments