From c980c77b28f23f262e77137fb433e2858b60a1d2 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 28 May 2015 13:06:09 +0800 Subject: [PATCH] src/Builder4/Editor.bjs src/Builder4/Editor.vala --- src/Builder4/Editor.bjs | 2 +- src/Builder4/Editor.vala | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Builder4/Editor.bjs b/src/Builder4/Editor.bjs index 040ee8893..c6bbbdbd4 100644 --- a/src/Builder4/Editor.bjs +++ b/src/Builder4/Editor.bjs @@ -73,7 +73,7 @@ "gboolean highlight_current_line" : true, "$ gboolean auto_indent" : true, "$ xns" : "Gtk", - "| void load" : " (string str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n buf.set_text(str, str.length);\n buf.set_undo_manager(null);\n \n var lm = Gtk.SourceLanguageManager.get_default();\n var lang = \"vala\";\n if (_this.file != null) {\n lang = _this.file.language;\n }\n //?? is javascript going to work as js?\n \n ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language(lang));\n \n \n _this.dirty = false;\n this.el.grab_focus();\n _this.save_button.el.sensitive = false;\n}", + "| void load" : " (string str) {\n\n// show the help page for the active node..\n //this.get('/Help').show();\n\n\n // this.get('/BottomPane').el.set_current_page(0);\n var buf = (Gtk.SourceBuffer)this.el.get_buffer();\n buf.set_text(str, str.length);\n buf.set_undo_manager(null);\n \n var lm = Gtk.SourceLanguageManager.get_default();\n var lang = \"vala\";\n if (_this.file != null) {\n lang = _this.file.language;\n }\n \n \n ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(\n _this.file.content_type.length > 0 ?\n lm.guess_language(_this.file.path, _this.file.content_type) :\n lm.get_language(lang)\n );\n \n \n _this.dirty = false;\n this.el.grab_focus();\n _this.save_button.el.sensitive = false;\n}", "indent_width" : 4, "$ show_line_numbers" : true, "items" : [ diff --git a/src/Builder4/Editor.vala b/src/Builder4/Editor.vala index f2d39237a..fe189b6bc 100644 --- a/src/Builder4/Editor.vala +++ b/src/Builder4/Editor.vala @@ -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; -- 2.39.2