From e33159a0b338ebad4ac48cb19c7e01c7d21c4cf9 Mon Sep 17 00:00:00 2001 From: ninth-dev <4069123+ninth-dev@users.noreply.github.com> Date: Tue, 30 Aug 2022 18:24:50 +1000 Subject: [PATCH] Fix logic error in _return_existing_view --- plugin/core/open.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/core/open.py b/plugin/core/open.py index 058463665..dfc050dc3 100644 --- a/plugin/core/open.py +++ b/plugin/core/open.py @@ -15,15 +15,16 @@ opening_files = {} # type: Dict[str, Tuple[Promise[Optional[sublime.View]], ResolveFunc[Optional[sublime.View]]]] -def _return_existing_view(flags: int, is_view_in_active_group: bool, specified_group: int) -> bool: +def _return_existing_view(flags: int, existing_view_group: int, active_group: int, specified_group: int) -> bool: # the specified_group is supplied if specified_group > -1: - return is_view_in_active_group + # use existing_view_group if it is in the specified group + return existing_view_group == specified_group # open side by side if bool(flags & (sublime.ADD_TO_SELECTION | sublime.REPLACE_MRU)): return False - # view is in active group ( no group is specified and not side by side ) - if is_view_in_active_group: + # existing view is in active group ( no group is specified and not side by side ) + if existing_view_group == active_group: return True # Jump to the file if sublime.FORCE_GROUP is not set return not bool(flags & sublime.FORCE_GROUP) @@ -41,7 +42,7 @@ def open_file( # window.open_file brings the file to focus if it's already opened, which we don't want (unless it's supposed # to open as a separate view). view = window.find_open_file(file) - if view and _return_existing_view(flags, window.get_view_index(view)[0] == window.active_group(), group): + if view and _return_existing_view(flags, window.get_view_index(view)[0], window.active_group(), group): return Promise.resolve(view) view = window.open_file(file, flags, group)