Repository: sublimelsp/LSP

Issue:
`force_group` argument support for `lsp_symbol_references` command
Working in multiple groups, `lsp_symbol_references` command doesn't work across groups but instead duplicates already open files when one of the listed references is selected to open. It should have a flag to disable `force_group` setting.


Discussion:
For the quick panel (`"show_references_in_quick_panel": true`) it should be pretty simple to add; just pass the `force_group` argument further to
https://github.com/sublimelsp/LSP/blob/ea73d99fce5208c3166f21c69c4b9b8ae4e2017d/plugin/references.py#L122

But for the output panel, which is still the default setting, I think it's not possible to control this. Because the only thing LSP does is to set the "result_file_regex" and "result_line_regex" setting for that output view, and ST's native build result navigation takes care of the rest.

https://github.com/sublimelsp/LSP/blob/ea73d99fce5208c3166f21c69c4b9b8ae4e2017d/plugin/core/panels.py#L92-L96

Resolving patch:
diff --git a/plugin/references.py b/plugin/references.py
--- a/plugin/references.py
+++ b/plugin/references.py
@@ -28,7 +28,9 @@ def is_enabled(
         event: Optional[dict] = None,
         point: Optional[int] = None,
         side_by_side: bool = False,
+        force_group: bool = True,
         fallback: bool = False,
+        group: int = -1
     ) -> bool:
         return fallback or super().is_enabled(event, point)
 
@@ -37,7 +39,9 @@ def is_visible(
         event: Optional[dict] = None,
         point: Optional[int] = None,
         side_by_side: bool = False,
+        force_group: bool = True,
         fallback: bool = False,
+        group: int = -1
     ) -> bool:
         if self.applies_to_context_menu(event):
             return self.is_enabled(event, point, side_by_side, fallback)
@@ -49,7 +53,9 @@ def run(
         event: Optional[dict] = None,
         point: Optional[int] = None,
         side_by_side: bool = False,
+        force_group: bool = True,
         fallback: bool = False,
+        group: int = -1
     ) -> None:
         session = self.best_session(self.capability)
         file_path = self.view.file_name()
@@ -70,7 +76,9 @@ def run(
                     self.view.substr(word_range),
                     session,
                     side_by_side,
+                    force_group,
                     fallback,
+                    group,
                     word_range.begin()
                 )
             )
@@ -82,24 +90,30 @@ def _handle_response_async(
         word: str,
         session: Session,
         side_by_side: bool,
+        force_group: bool,
         fallback: bool,
+        group: int,
         position: int,
         response: Optional[List[Location]]
     ) -> None:
-        sublime.set_timeout(lambda: self._handle_response(word, session, side_by_side, fallback, position, response))
+        sublime.set_timeout(lambda: self._handle_response(
+            word, session, side_by_side, force_group, fallback, group, position, response))
 
     def _handle_response(
         self,
         word: str,
         session: Session,
         side_by_side: bool,
+        force_group: bool,
         fallback: bool,
+        group: int,
         position: int,
         response: Optional[List[Location]]
     ) -> None:
         if response:
             if userprefs().show_references_in_quick_panel:
-                self._show_references_in_quick_panel(word, session, response, side_by_side, position)
+                self._show_references_in_quick_panel(
+                    word, session, response, side_by_side, force_group, group, position)
             else:
                 self._show_references_in_output_panel(word, session, response)
         else:
@@ -115,11 +129,19 @@ def _handle_no_results(self, fallback: bool = False, side_by_side: bool = False)
             window.status_message("No references found")
 
     def _show_references_in_quick_panel(
-        self, word: str, session: Session, locations: List[Location], side_by_side: bool, position: int
+        self,
+        word: str,
+        session: Session,
+        locations: List[Location],
+        side_by_side: bool,
+        force_group: bool,
+        group: int,
+        position: int
     ) -> None:
         self.view.run_command("add_jump_record", {"selection": [(r.a, r.b) for r in self.view.sel()]})
+        placeholder = "References to " + word
         kind = get_symbol_kind_from_scope(self.view.scope_name(position))
-        LocationPicker(self.view, session, locations, side_by_side, placeholder="References to " + word, kind=kind)
+        LocationPicker(self.view, session, locations, side_by_side, force_group, group, placeholder, kind)
 
     def _show_references_in_output_panel(self, word: str, session: Session, locations: List[Location]) -> None:
         wm = windows.lookup(session.window)


Test patch: