Skip to content

Commit

Permalink
Fix logic error in _return_existing_view
Browse files Browse the repository at this point in the history
  • Loading branch information
ninth-dev committed Aug 30, 2022
1 parent 1fb2f86 commit e33159a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugin/core/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e33159a

Please sign in to comment.