" _this.file.setSource(str);",
"\t BuilderApplication.showSpinner(\"appointment soon\",\"document change pending\");",
" \t_this.file.getLanguageServer().document_change(_this.file);",
- "",
+ "\t\t_this.file.getLanguageServer().queueDocumentSymbols(_this.file);",
" _this.file.setSource(oldcode);",
" ",
"\t\t ",
"\tforeach(var sym in syms) {",
"\t\t_this.navliststore.el.append(sym);",
"\t}",
- "\t",
+ "\tthis.last_selected_line = -1;",
+ "\tGLib.Idle.add(() => {",
+ "",
+ "\t\tGtk.TextIter iter;",
+ "\t\t_this.buffer.el.get_iter_at_offset (",
+ "\t\t\t\tout iter, _this.buffer.el.cursor_position);",
+ "\t\t",
+ "\t\tGLib.debug(\"idle update scroll %d, %d\", iter.get_line(),",
+ "\t\t\t\titer.get_line_offset());",
+ "\t\tthis.updateSelectedLine(",
+ "\t\t\t\t(uint)iter.get_line(),",
+ "\t\t\t\t(uint)iter.get_line_offset()",
+ "\t\t);",
+ "\t\treturn false;",
+ "\t});",
"",
"}"
],
"(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
"{",
" this.reset();",
+ " if (this.file != null) {",
+ " \tthis.file.navigation_tree_updated.disconnect(",
+ " \t\t_this.navigation.show",
+ " \t);",
+ " }",
" this.file = file; ",
- " ",
+ " this.file.navigation_tree_updated.connect(",
+ "\t\t_this.navigation.show",
+ "\t);",
" if (file.xtype != \"PlainFile\") {",
" \tthis.prop = prop;",
" this.node = node;",
" ",
" } else {",
" this.view.load( file.toSource() );",
- " this.updateErrorMarks();",
+ " this.updateErrorMarks();",
" this.close_btn.el.hide();",
" var ls = file.getLanguageServer();",
- " ls.documentSymbols.begin(file, (a,o) => {",
- " \t_this.navigation.show(ls.documentSymbols.end(o)); ",
- " });",
+ " ls.queueDocumentSymbols(file);",
+ " ////ls.documentSymbols.begin(file, (a,o) => {",
+ " //\t_this.navigation.show(ls.documentSymbols.end(o)); ",
+ " //});",
" //documentSymbols",
" ",
" }",
public void show (JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)
{
this.reset();
+ if (this.file != null) {
+ this.file.navigation_tree_updated.disconnect(
+ _this.navigation.show
+ );
+ }
this.file = file;
-
+ this.file.navigation_tree_updated.connect(
+ _this.navigation.show
+ );
if (file.xtype != "PlainFile") {
this.prop = prop;
this.node = node;
} else {
this.view.load( file.toSource() );
- this.updateErrorMarks();
+ this.updateErrorMarks();
this.close_btn.el.hide();
var ls = file.getLanguageServer();
- ls.documentSymbols.begin(file, (a,o) => {
- _this.navigation.show(ls.documentSymbols.end(o));
- });
+ ls.queueDocumentSymbols(file);
+ ////ls.documentSymbols.begin(file, (a,o) => {
+ // _this.navigation.show(ls.documentSymbols.end(o));
+ //});
//documentSymbols
}
_this.file.setSource(str);
BuilderApplication.showSpinner("appointment soon","document change pending");
_this.file.getLanguageServer().document_change(_this.file);
-
+ _this.file.getLanguageServer().queueDocumentSymbols(_this.file);
_this.file.setSource(oldcode);
foreach(var sym in syms) {
_this.navliststore.el.append(sym);
}
-
+ this.last_selected_line = -1;
+ GLib.Idle.add(() => {
+
+ Gtk.TextIter iter;
+ _this.buffer.el.get_iter_at_offset (
+ out iter, _this.buffer.el.cursor_position);
+
+ GLib.debug("idle update scroll %d, %d", iter.get_line(),
+ iter.get_line_offset());
+ this.updateSelectedLine(
+ (uint)iter.get_line(),
+ (uint)iter.get_line_offset()
+ );
+ return false;
+ });
}
public int getRowAt (double x, double y, out string pos) {
}
//public signal void changed (Node? node, string source); (not used?)
-
+ public signal void navigation_tree_updated( Gee.ArrayList<Lsp.DocumentSymbol> syms);
public signal void compile_notice(string type, string file, int line, string message);
public abstract async void shutdown () throws GLib.Error;
public abstract async Lsp.CompletionList? completion(JsRender.JsRender file, int line, int offset , int triggerType = 1) throws GLib.Error;
public abstract async Lsp.Hover hover (JsRender.JsRender file, int line, int offset) throws GLib.Error;
+ public abstract void queueDocumentSymbols (JsRender.JsRender file);
public abstract async Gee.ArrayList<Lsp.DocumentSymbol> documentSymbols (JsRender.JsRender file) throws GLib.Error;
}
public override async Lsp.Hover hover (JsRender.JsRender file, int line, int offset) throws GLib.Error {
return new Lsp.Hover();
}
+ public override void queueDocumentSymbols (JsRender.JsRender file) { }
public override async Gee.ArrayList<Lsp.DocumentSymbol> documentSymbols (JsRender.JsRender file) throws GLib.Error {
var ret = new Gee.ArrayList<Lsp.DocumentSymbol>();
return ret;
public override async Lsp.Hover hover (JsRender.JsRender file, int line, int offset) throws GLib.Error {
return new Lsp.Hover();
}
+ public override void queueDocumentSymbols (JsRender.JsRender file) { }
public override async Gee.ArrayList<Lsp.DocumentSymbol> documentSymbols (JsRender.JsRender file) throws GLib.Error {
var ret = new Gee.ArrayList<Lsp.DocumentSymbol>();
return ret;
namespace Palete {
public class LanguageClientVala : LanguageClient {
- int countdown = 0;
protected bool initialized = false;
bool sent_shutdown = false;
uint change_queue_id = 0;
private IOStream? subprocess_stream = null;
public Jsonrpc.Client? jsonrpc_client = null;
+ int countdown = 0;
Gee.ArrayList<JsRender.JsRender> open_files;
private JsRender.JsRender? _change_queue_file = null;
+ int doc_countdown = 0;
private string change_queue_file_source = "";
+ private JsRender.JsRender? doc_queue_file = null;
+
JsRender.JsRender? change_queue_file {
set {
return this._change_queue_file;
}
}
+
+
+
void startServer()
{
var exe = GLib.Environment.find_program_in_path( "vala-language-server");
// extend versions will proably call initialize to start and connect to server.
base(project);
- this.change_queue_id = GLib.Timeout.add_seconds(1, () => {
- if (this.change_queue_file == null) {
- return true;
- }
- if (this.getting_diagnostics) {
- return true;
- }
- this.countdown--;
-
+ if (this.change_queue_id == 0 ) {
+ this.change_queue_id = GLib.Timeout.add_seconds(1, () => {
+ this.run_change_queue();
+ this.run_doc_queue();
+ return true;
+ });
+ }
- if (this.countdown < 0){
- this.document_change_force.begin(this.change_queue_file, this.change_queue_file_source, (o, res) => {
- this.document_change_force.end(res);
- });
- this.change_queue_file = null;
-
- }
- return true;
- });
this.startServer();
}
+ void run_change_queue()
+ {
+
+ if (this.change_queue_file == null) {
+ return ;
+ }
+ if (this.countdown < -1) {
+ return;
+ }
+ if (this.getting_diagnostics) {
+ return;
+ }
+ this.countdown--;
+
+
+ if (this.countdown < 0){
+ this.document_change_force.begin(this.change_queue_file, this.change_queue_file_source, (o, res) => {
+ this.document_change_force.end(res);
+ });
+ this.change_queue_file = null;
+
+ }
+ return ;
+ }
+
+ void run_doc_queue()
+ {
+
+ if (this.doc_queue_file == null) {
+ return ;
+ }
+ if (this.doc_countdown < -1) {
+ return;
+ }
+ this.doc_countdown--;
+
+ if (this.doc_countdown < 0){
+ var sendfile = this.doc_queue_file;
+ this.documentSymbols.begin(this.doc_queue_file, (o, res) => {
+ var ret = this.documentSymbols.end(res);
+ sendfile.navigation_tree_updated(ret);
+ });
+ this.doc_queue_file = null;
+
+ }
+ return ;
+ }
public bool initProcess(string process_path)
{
this.onClose();
}
-
+ 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);
+ });
+ }
+
+ this.doc_countdown = 3;
+ this.doc_queue_file = file;
+ }
public override async Gee.ArrayList<Lsp.DocumentSymbol> documentSymbols (JsRender.JsRender file) throws GLib.Error {