Skip to content

Commit f85912b

Browse files
authored
Disable workaround for on_post_move_async listener not triggering (#2582)
1 parent fb0fc75 commit f85912b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

boot.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .plugin.configuration import LspDisableLanguageServerInProjectCommand
1818
from .plugin.configuration import LspEnableLanguageServerGloballyCommand
1919
from .plugin.configuration import LspEnableLanguageServerInProjectCommand
20+
from .plugin.core.constants import ST_VERSION
2021
from .plugin.core.css import load as load_css
2122
from .plugin.core.open import opening_files
2223
from .plugin.core.panels import PanelName
@@ -226,18 +227,18 @@ def on_new_window_async(self, w: sublime.Window) -> None:
226227
def on_pre_close_window(self, w: sublime.Window) -> None:
227228
windows.discard(w)
228229

229-
# Note: EventListener.on_post_move_async does not fire when a tab is moved out of the current window in such a way
230-
# that a new window is created: https://github.com/sublimehq/sublime_text/issues/4630
231-
# Hence, as a workaround we use on_pre_move, which still works in that case.
232230
def on_pre_move(self, view: sublime.View) -> None:
233-
listeners = sublime_plugin.view_event_listeners.get(view.id())
234-
if not isinstance(listeners, list):
235-
return
236-
for listener in listeners:
237-
if isinstance(listener, DocumentSyncListener):
238-
# we need a small delay here, so that the DocumentSyncListener will recognize a possible new window
239-
sublime.set_timeout_async(listener.on_post_move_window_async, 1)
231+
if ST_VERSION < 4184: # https://github.com/sublimehq/sublime_text/issues/4630#issuecomment-2502781628
232+
# Workaround for ViewEventListener.on_post_move_async not being triggered when air-dropping a tab:
233+
# https://github.com/sublimehq/sublime_text/issues/4630
234+
listeners = sublime_plugin.view_event_listeners.get(view.id())
235+
if not isinstance(listeners, list):
240236
return
237+
for listener in listeners:
238+
if isinstance(listener, DocumentSyncListener):
239+
# we need a small delay here, so that the DocumentSyncListener will recognize a possible new window
240+
sublime.set_timeout_async(listener.on_post_move_window_async, 1)
241+
return
241242

242243
def on_load(self, view: sublime.View) -> None:
243244
file_name = view.file_name()

plugin/documents.py

+5
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ def on_load_async(self) -> None:
385385
partial(self._on_initial_folding_ranges, initially_folded_kinds))
386386
self.on_activated_async()
387387

388+
def on_post_move_async(self) -> None:
389+
if ST_VERSION < 4184: # Already handled in boot.Listener.on_pre_move
390+
return
391+
self.on_post_move_window_async()
392+
388393
def on_activated_async(self) -> None:
389394
if self.view.is_loading() or not is_regular_view(self.view):
390395
return

0 commit comments

Comments
 (0)