From 7d335029b8ebb6022656a1aea9386f7f8cc6f36f Mon Sep 17 00:00:00 2001 From: kohnish Date: Wed, 1 Mar 2023 23:01:37 +0100 Subject: [PATCH] format timer delay improvement --- autoload/lsc/common.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/lsc/common.vim b/autoload/lsc/common.vim index 533708a..e681cc3 100644 --- a/autoload/lsc/common.vim +++ b/autoload/lsc/common.vim @@ -527,8 +527,13 @@ def FormatCb(bnr: number, text_edits: list>): void setpos('.', orig_cursor_pos) enddef +def Reset_format_delay(arg: any): void + g_format_delay = false +enddef + def Format_(arg: any): void g_format_delay = true + timer_start(1000, Reset_format_delay) lsc#file#flushChanges() var params: dict params = { 'textDocument': { 'uri': Uri() } } @@ -540,7 +545,6 @@ enddef export def Format(): void if g_format_delay - g_format_delay = false timer_start(1000, Format_) else Format_(0)