Skip to content

Commit ac28831

Browse files
committed
use debounced from LSP
1 parent 84f4109 commit ac28831

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

listener.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
logger = logging.getLogger(__name__)
99

1010
from LSP.plugin.core.registry import windows
11-
from LSP.plugin.core.types import FEATURES_TIMEOUT
11+
from LSP.plugin.core.types import FEATURES_TIMEOUT, debounced
1212

1313

1414
class TriggerInfo:
@@ -143,8 +143,12 @@ def _kick(self, view, generate_imports=True, timestamp=None):
143143

144144
def on_modified_async(self, view):
145145
timestamp = time.perf_counter()
146-
sublime.set_timeout_async(
147-
lambda: self._kick(view, True, timestamp=timestamp), FEATURES_TIMEOUT
146+
change_count = view.change_count()
147+
debounced(
148+
lambda: self._kick(view, False, timestamp=timestamp),
149+
FEATURES_TIMEOUT,
150+
lambda: view.is_valid() and change_count == view.change_count(),
151+
async_thread=True,
148152
)
149153

150154
def on_load_async(self, view):

0 commit comments

Comments
 (0)