src/Builder4/Editor.bjs
[app.Builder.js] / src / Builder4 / Editor.vala
index b91d5c5..dfbbc8c 100644 (file)
@@ -336,7 +336,7 @@ public class Editor : Object
         
         
           // this.get('/BottomPane').el.set_current_page(0);
-          var buf = (Gtk.SourceBuffer)this.el.get_buffer();
+            var buf = (Gtk.SourceBuffer)this.el.get_buffer();
             buf.set_text(str, str.length);
             buf.set_undo_manager(null);
             
@@ -345,9 +345,13 @@ public class Editor : Object
             if (_this.file != null) {
                  lang = _this.file.language;
             }
-            //?? is javascript going to work as js?
             
-            ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang));
+         
+            ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(
+                    _this.file.content_type.length > 0  ?
+                    lm.guess_language(_this.file.path, _this.file.content_type) :
+                    lm.get_language(lang)
+                );
          
              
             _this.dirty = false;
@@ -551,7 +555,7 @@ public class Editor : Object
             
             }
             var valafn = _this.file.path;
-            print("%s : %s", _this.file.path, _this.file.xtype);
+         
             if (_this.file.xtype != "PlainFile") {
         
         
@@ -560,9 +564,8 @@ public class Editor : Object
                  valafn = "";
                   try {             
                        var  regex = new Regex("\\.bjs$");
-                        if (_this.file == null) {
-                            return true;
-                        }
+                       // should not happen
+                      
                      
                         valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".vala");
                      } catch (GLib.RegexError e) {