Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
- Update the feature documentation
- remove redundant variables
- add group in is_enabled
  • Loading branch information
ninth-dev committed Aug 30, 2022
1 parent 705e710 commit 1fb2f86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/src/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ In addition to the basic "Goto Definition", the protocol also provides further r
Additionally, the LSP's "Goto Definition" command can fall back to the built-in Sublime's "Goto Definition" if the `fallback` argument is set to `true`.
This way, when there are no results found the built-in "Goto Definition" command will be triggered.

To always open the results in a certain group, you can use the `group` argument.
To attempt to open the results in a certain group, you can use the `group` argument. If the specified `group` does not exist, then it will be ignored.

## Find References

Expand Down
17 changes: 6 additions & 11 deletions plugin/core/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
opening_files = {} # type: Dict[str, Tuple[Promise[Optional[sublime.View]], ResolveFunc[Optional[sublime.View]]]]


def _return_existing_view(flags: int, existing_view_group: int, active_group: int, specified_group: int) -> bool:
def _return_existing_view(flags: int, is_view_in_active_group: bool, specified_group: int) -> bool:
# the specified_group is supplied
if specified_group > -1:
# use existing_view_group if it is in the active group
return existing_view_group == active_group
return is_view_in_active_group
# open side by side
if bool(flags & (sublime.ADD_TO_SELECTION | sublime.REPLACE_MRU)):
return False
# existing view is in active group ( no group is specified and not side by side )
if existing_view_group == active_group:
# view is in active group ( no group is specified and not side by side )
if is_view_in_active_group:
return True
# Jump to the file if sublime.FORCE_GROUP is not set
return not bool(flags & sublime.FORCE_GROUP)
Expand All @@ -42,12 +41,8 @@ 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:
return_existing_view = _return_existing_view(
flags, window.get_view_index(view)[0], window.active_group(), group
)
if return_existing_view:
return Promise.resolve(view)
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)
if not view.is_loading():
Expand Down
3 changes: 2 additions & 1 deletion plugin/goto.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def is_enabled(
point: Optional[int] = None,
side_by_side: bool = False,
force_group: bool = True,
fallback: bool = False
fallback: bool = False,
group: int = -1
) -> bool:
return fallback or super().is_enabled(event, point)

Expand Down

0 comments on commit 1fb2f86

Please sign in to comment.