Fix #8003 - undo code
[roobuilder] / src / Palete / LanguageClientVala.vala
index b92035e..4c78905 100644 (file)
@@ -43,7 +43,7 @@ namespace Palete {
                {
                        // extend versions will proably call initialize to start and connect to server.
                        base(project);
-                       this.open_files = new   Gee.ArrayList<JsRender.JsRender>();
+
                        this.change_queue_id = GLib.Timeout.add_seconds(1, () => {
                                if (this.change_queue_file == null) {
                                        return true;
@@ -151,6 +151,9 @@ namespace Palete {
                                    out return_value
                                );
                                GLib.debug ("LS replied with %s", Json.to_string (Json.gvariant_serialize (return_value), true));
+                               this.open_files = new Gee.ArrayList<JsRender.JsRender>((a,b) => {
+                                       return a.path == b.path;
+                               });
                                this.initialized = true;
                                return;
                        } catch (GLib.Error e) {
@@ -201,9 +204,7 @@ namespace Palete {
                public async void restartServer()
                {
                        this.startServer();
-                       foreach(var f in this.open_files) {
-                               this.document_open(f);
-                       }
+                        
                }
        
                public bool isReady()
@@ -266,6 +267,7 @@ namespace Palete {
                                //this.project.updateErrorsforFile(null);
                                return;
                        }
+                       //GLib.debug("got Diagnostics for %s", f.path);
                        f.updateErrors( dg.diagnostics );
                         
                        
@@ -276,9 +278,11 @@ namespace Palete {
                        if (!this.isReady()) {
                                return;
                        }
-                       if (!this.open_files.contains(file)) {
-                               this.open_files.add(file);
+                       if (this.open_files.contains(file)) {
+                               return;
                        }
+                       this.open_files.add(file);
+                       
                        
                        GLib.debug ("LS sent open");                     
                        try {
@@ -395,9 +399,11 @@ namespace Palete {
                        if (!this.isReady()) {
                                return;
                        }
-                            
+                  if (!this.open_files.contains(file)) {
+                                this.document_open(file);
+                       }  
                        
-                       GLib.debug ("LS send change");
+                       GLib.debug ("LS send change %s rev %d", file.path, file.version);
                        var ar = new Json.Array();
                        var obj = new Json.Object();
                        obj.set_string_member("text", contents);