Skip to content

Commit

Permalink
Merge 6e869a3 into 7fd517b
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Jul 9, 2019
2 parents 7fd517b + 6e869a3 commit d2ffc55
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions common/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
EDIT_DEFAULT_HELP_TEXT = "## To finalize your edit, press {super_key}+Enter. To cancel, close the view.\n"


def focus_view(view):
window = view.window()
if not window:
return

group, _ = window.get_view_index(view)
window.focus_group(group)
window.focus_view(view)


class Interface():

interface_type = ""
Expand All @@ -35,9 +45,11 @@ def __new__(cls, repo_path=None, **kwargs):
window = sublime.active_window()
for view in window.views():
vset = view.settings()
if vset.get("git_savvy.interface") == cls.interface_type and \
vset.get("git_savvy.repo_path") == repo_path:
window.focus_view(view)
if (
vset.get("git_savvy.interface") == cls.interface_type
and vset.get("git_savvy.repo_path") == repo_path
):
focus_view(view)
try:
return interfaces[view.id()]
except KeyError:
Expand Down Expand Up @@ -97,7 +109,7 @@ def create_view(self, repo_path):
self.view.set_name(self.title())

self.render()
window.focus_view(self.view)
focus_view(self.view)

return self.view

Expand Down

0 comments on commit d2ffc55

Please sign in to comment.