Skip to content

Commit

Permalink
workaround for View Listeners not being attached for new transient vi…
Browse files Browse the repository at this point in the history
…ew (#2174)
  • Loading branch information
rchl authored Jan 22, 2023
1 parent 01ca49e commit ff57279
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plugin/core/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import re
import sublime
import sublime_plugin
import subprocess
import webbrowser

Expand Down Expand Up @@ -86,8 +87,13 @@ def open_file(
if view and _return_existing_view(flags, window.get_view_index(view)[0], window.active_group(), group):
return Promise.resolve(view)

was_already_open = view is not None
view = window.open_file(file, flags, group)
if not view.is_loading():
if was_already_open and (flags & sublime.SEMI_TRANSIENT):
# workaround bug https://github.com/sublimehq/sublime_text/issues/2411 where transient view might not get
# its view listeners initialized.
sublime_plugin.check_view_event_listeners(view) # type: ignore
# It's already loaded. Possibly already open in a tab.
return Promise.resolve(view)

Expand Down

0 comments on commit ff57279

Please sign in to comment.