this.in_populate = true;
global::Gtk.TextIter begin, end;
- Lsp.CompletionList res;
+
+
+ var expression = new global::Gtk.PropertyExpression(typeof(CompletionProposal), null, "label");
+
if (context.get_bounds (out begin, out end)) {
+ this.model = new CompletionModel(this, context, cancellable);
+ var word = context.get_word();
+
+ var lc = end.copy();
+ lc.backward_char();
+ var lchar = lc.get_text(end);
+
+
+ GLib.debug("Context word is %s / '%s' , %d", word, lchar, (int)word.length);
+ if (word.length < 1 && lchar != ".") {
+ word = " "; // this should filter out everything, and prevent it displaying
+ }
+ this.filter = new global::Gtk.StringFilter(expression);
+ this.filter.set_search( word);
+ var filter_model = new global::Gtk.FilterListModel(this.model, this.filter);
+
+ filter.match_mode = global::Gtk.StringFilterMatchMode.PREFIX;
+ filter_model.set_incremental(true);
+
+
var line = end.get_line();
var offset = end.get_line_offset();
if (this.editor.prop != null) {
}
}
// this should not really be slow, as it's a quick repsonse
- yield this.file.getLanguageServer().document_change_force(this.file, this.editor.tempFileContents());
+ var ls = this.file.getLanguageServer();
+ yield ls.document_change_force(this.file, this.editor.tempFileContents());
+
+
+ GLib.debug("sending request to language server %s", this.file.getLanguageServer().get_type().name());
try {
- GLib.debug("sending request to language server %s", this.file.getLanguageServer().get_type().name());
-
- res = yield this.file.getLanguageServer().completion(this.file, line, offset, 1);
- } catch (GLib.Error e) {
+ var res = yield ls.completion(this.file, line, offset, 1);
+ this.model.updateList(res);
+ } catch(GLib.Error e) {
GLib.debug("got error %s", e.message);
this.in_populate = false;
- return ret;
+ return ret; // empty.
}
+ // got a result...
+
+ GLib.debug("pupoulate async - got reply");
+
- } else {
- this.in_populate = false;
- return ret;
- }
-
- GLib.debug("pupoulate async - got reply");
- this.model = new CompletionModel(this, context, res, cancellable);
- var word = context.get_word();
-
- var lc = end.copy();
- lc.backward_char();
- var lchar = lc.get_text(end);
-
-
- GLib.debug("Context word is %s / '%s' , %d", word, lchar, (int)word.length);
- if (word.length < 1 && lchar != ".") {
- word = " "; // this should filter out everything, and prevent it displaying
- }
- var expression = new global::Gtk.PropertyExpression(typeof(CompletionProposal), null, "label");
- this.filter = new global::Gtk.StringFilter(expression);
- this.filter.set_search( word);
- var filter_model = new global::Gtk.FilterListModel(this.model, this.filter);
- filter.match_mode = global::Gtk.StringFilterMatchMode.PREFIX;
- filter_model.set_incremental(true);
+ this.in_populate = false;
+
+
+
+ return filter_model;
+
+ }
this.in_populate = false;
- return filter_model;
-
+ return ret;
+
}
public Cancellable? cancellable;
- public CompletionModel(CompletionProvider provider, GtkSource.CompletionContext context, Lsp.CompletionList? res, Cancellable? cancellable)
+ public CompletionModel(CompletionProvider provider, GtkSource.CompletionContext context, Cancellable? cancellable)
{
this.provider = provider;
this.cancellable = cancellable;
var word = context.get_word();
GLib.debug("looking for %s", word);
this.search = word;
- if (res != null) {
- foreach(var comp in res.items) {
- if (comp.label == "_") { // skip '_'
- continue;
- }
- GLib.debug("got suggestion %s", comp.label);
- this.items.add(new CompletionProposal(comp));
-
- }
- }
- GLib.debug("GOT %d results\n", (int) items.size);
+
+ //GLib.debug("GOT %d results\n", (int) items.size);
// WHY TWICE?
- if (this.items.size < this.minimum_word_size) {
- return;
- }
-
- items.sort((a, b) => {
- return ((string)(a.label)).collate((string)(b.label));
- });
+ this.items.add(new CompletionProposal(new Lsp.CompletionItem.keyword ("Loading...")));
}
-
+ public void updateList( Lsp.CompletionList? res )
+ {
+ this.items.clear();
+ foreach(var comp in res.items) {
+ if (comp.label == "_") { // skip '_'
+ continue;
+ }
+ GLib.debug("got suggestion %s", comp.label);
+ this.items.add(new CompletionProposal(comp));
+ }
+
+ this.items.sort((a, b) => {
+ return ((string)(a.label)).collate((string)(b.label));
+ });
+ }
+
public GLib.Object? get_item (uint pos)
public override void document_change (JsRender.JsRender file )
{
+ this.change_queue_file = file;
+ this.document_change_force.begin(this.change_queue_file, this.change_queue_file_source, (o, res) => {
+ this.document_change_force.end(res);
+ });
+ return;
+ /*
if (this.change_queue_file != null && this.change_queue_file.path != file.path) {
this.document_change_force.begin(this.change_queue_file, this.change_queue_file_source, (o, res) => {
this.document_change_force.end(res);
this.countdown = 2;
this.change_queue_file = file;
-
+ */
}
public override void queueDocumentSymbols (JsRender.JsRender file)
{
+ this.doc_queue_file = file;
+ this.documentSymbols.begin(this.doc_queue_file, (o, res) => {
+ try {
+ var ret = documentSymbols.end(res);
+ file.navigation_tree_updated(ret);
+ } catch(GLib.Error e) {}
+ });
+ return;
+ /*
+
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) => {
this.doc_countdown = 2;
this.doc_queue_file = file;
+ */
}