Fix #7991 - better updateing of error status and char position of errors
[roobuilder] / src / Builder4 / GtkView.vala
index 4430440..d7a1ee9 100644 (file)
@@ -34,6 +34,7 @@ public class Xcls_GtkView : Object
        public Gtk.CssProvider css;
        public Xcls_MainWindow main_window;
        public GtkSource.SearchContext searchcontext;
+       public int last_error_counter;
        public int last_search_end;
        public JsRender.JsRender file;
 
@@ -45,6 +46,7 @@ public class Xcls_GtkView : Object
 
                // my vars (dec)
                this.lastObj = null;
+               this.last_error_counter = 0;
                this.last_search_end = 0;
                this.file = null;
 
@@ -82,15 +84,17 @@ public class Xcls_GtkView : Object
                if (file.tree == null) {
                    return;
                }
+               this.last_error_counter = -1;
                this.notebook.el.page = 0;// gtk preview 
           
          
                
               this.file = file;     
                this.sourceview.loadFile();
+              
                this.searchcontext = null;
-               
-       
+               this.last_error_counter = -1;
+                       this.updateErrorMarks();
                if (this.lastObj != null) {
                    this.container.el.remove(this.lastObj);
                }
@@ -126,19 +130,7 @@ public class Xcls_GtkView : Object
                this.createThumb();
                 
                         
-              return;/*
-               var x = new JsRender.NodeToGtk((Project.Gtk) file.project, file.tree);
-           var obj = x.munge() as Gtk.Widget;
-           this.lastObj = null;
-               if (obj == null) {
-                       return;
-               }
-               this.lastObj = obj;
-               
-               this.container.el.append(obj);
-               obj.show();
-               
-                */
+              
                
        }
        public void highlightNodeAtLine (int ln) {
@@ -328,7 +320,7 @@ public class Xcls_GtkView : Object
            
             
        }
-       public void updateErrorMarks (string category) {
+       public void updateErrorMarks () {
                
         
        
@@ -337,7 +329,7 @@ public class Xcls_GtkView : Object
                Gtk.TextIter end;     
                buf.get_bounds (out start, out end);
        
-               buf.remove_source_marks (start, end, category);
+       
         
                GLib.debug("highlight errors");          
        
@@ -351,12 +343,17 @@ public class Xcls_GtkView : Object
                        return;
        
                }
-               var ar = this.file.getErrors(category);
-               if (ar == null || ar.get_n_items() < 1) {
-                       GLib.debug("higjlight %s has no errors", category);
+               var ar = this.file.getErrors();
+               if (ar.size < 1) {
+                       buf.remove_source_marks (start, end, null);
+                       this.last_error_counter = file.error_counter ;
+                       GLib.debug("higjlight has no errors");
                        return;
                }
-        
+               if (this.last_error_counter == file.error_counter) {
+                       return;
+               }
+               
        
         
                 
@@ -365,15 +362,13 @@ public class Xcls_GtkView : Object
                
         
                 
-               for (var i = 0; i < ar.get_n_items();i++) {
-                       var err = (Palete.CompileError) ar.get_item(i);
+               buf.remove_source_marks (start, end, null);
+               foreach(var diag in ar) { 
+               
                        
                     Gtk.TextIter iter;
        //        print("get inter\n");
-                   var eline = err.line + 1;
-                   GLib.debug("GOT ERROR on line %d -- converted to %d ",
-                       err.line ,eline);
-                   
+                   var eline = (int)diag.range.start.line ;
                    
                    if (eline > tlines || eline < 0) {
                        return;
@@ -383,12 +378,13 @@ public class Xcls_GtkView : Object
                    buf.get_iter_at_line( out iter, eline);
                   
                   
-                       var msg = "Line: %d %s : %s".printf(eline+1, err.category, err.msg);
-                   buf.create_source_mark( msg, err.category, iter);
+                  
+                       var msg = "Line: %d %s : %s".printf(eline+1, diag.category, diag.message);
+                   buf.create_source_mark( msg, diag.category, iter);
                    GLib.debug("set line %d to %s", eline, msg);
                    //this.marks.set(eline, msg);
                }
-               return ;
+               this.last_error_counter = file.error_counter ;