From f38f60dc7196b4ae10324e11e906f0d9bf9ab9ca Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 27 Mar 2024 17:54:34 +0800 Subject: [PATCH] src/Palete/LanguageClientVala.vala --- src/Palete/LanguageClientVala.vala | 49 ++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/Palete/LanguageClientVala.vala b/src/Palete/LanguageClientVala.vala index e6c01c628..53afb40fa 100644 --- a/src/Palete/LanguageClientVala.vala +++ b/src/Palete/LanguageClientVala.vala @@ -58,8 +58,7 @@ namespace Palete { if (this.change_queue_id == 0 ) { this.change_queue_id = GLib.Timeout.add(500, () => { - this.run_change_queue(); - this.run_doc_queue(); + this.run_change_queue(); return true; }); } @@ -93,7 +92,21 @@ namespace Palete { return ; } - + async int queuer(int cnt) + { + SourceFunc cb = this.queuer.callback; + + GLib.Timeout.add(500, () => { + GLib.Idle.add((owned) cb); + return false; + }); + + yield; + return cnt; + } + static int doc_queue_id = 0; + + /* void run_doc_queue() { @@ -116,7 +129,7 @@ namespace Palete { } return ; } - + */ public bool initProcess(string process_path) @@ -727,22 +740,32 @@ namespace Palete { } + + static int doc_symbol_queue_call_count = 1; + + + public override void queueDocumentSymbols (JsRender.JsRender file) { - if (this.doc_queue_file != null && this.doc_queue_file.path != file.path) { - var sendfile = this.doc_queue_file; - this.documentSymbols.begin(this.doc_queue_file, (o, res) => { - var ret = documentSymbols.end(res); - sendfile.navigation_tree_updated(ret); - }); + + + doc_symbol_queue_call_count++; + var call_id = yield this.queuer(doc_symbol_queue_call_count); + if (call_id != doc_symbol_queue_call_count) { + return; } + this.documentSymbols.begin(file, (o, res) => { + var ret = documentSymbols.end(res); + file.navigation_tree_updated(ret); + }); + - this.doc_countdown = 2; - this.doc_queue_file = file; + } - public override async Gee.ArrayList documentSymbols (JsRender.JsRender file) throws GLib.Error { + public override async Gee.ArrayList documentSymbols (JsRender.JsRender file) throws GLib.Error + { /* partial_result_token , work_done_token context = null) */ GLib.debug("get documentSymbols %s", file.relpath); var ret = new Gee.ArrayList(); -- 2.39.2