Fix #8005 - vala lang server path fix and crash on "..." in autocomplete signature
[roobuilder] / src / Palete / CompletionProvider.vala
index 9c365af..9ef4c63 100644 (file)
@@ -6,7 +6,6 @@ namespace Palete {
 
     public class CompletionProvider : Object, GtkSource.CompletionProvider
     {
-
                public JsRender.JsRender file {
                        get { return this.editor.file; }
                        private set {}
@@ -60,6 +59,10 @@ namespace Palete {
                                for(var i = 0 ; i < args.length; i++) {
                                        word += i > 0 ? ", " : " ";
                                        var wbit = args[i].strip().split(" ");
+                                       if (wbit.length < 2) {
+                                               word += wbit[0];
+                                               continue;
+                                       }
                                        var ty = wbit[wbit.length - 2];
                                        ty = ty.has_suffix("?") ? "?" : "";  
                                        word += ty + wbit[wbit.length-1]; // property type..?
@@ -197,14 +200,21 @@ namespace Palete {
                                var offset =  end.get_line_offset();
                                if (this.editor.prop != null) {
                                //      tried line -1 (does not work)
-                               
+                                       GLib.debug("node pad = '%s' %d", this.editor.node.node_pad, this.editor.node.node_pad.length);
+                                       
                                        line += this.editor.prop.start_line ; 
                                        // this is based on Gtk using tabs (hence 1/2 chars);
-                                       offset += this.editor.file.file_namespace == "" ? 1 : 2; 
+                                       offset += this.editor.node.node_pad.length;
+                                       // javascript listeners are indented 2 more spaces.
+                                       if (this.editor.prop.ptype == JsRender.NodePropType.LISTENER) {
+                                               offset += 2;
+                                       }
                                } 
                                
-                               this.file.getLanguageServer().document_change_real(this.file, this.editor.tempFileContents());                          
+                               yield this.file.getLanguageServer().document_change_force(this.file, this.editor.tempFileContents());                           
                                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) {
                                        GLib.debug("got error %s", e.message);