diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 3616d59246..0cfee4d666 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -270,16 +270,21 @@ public class Code.FormatBar : Gtk.Box { goto_entry.text = "%d.%d".printf (line, iter.get_line_offset () + 1); } - public void set_document (Scratch.Services.Document doc) { - if (this.doc != null) { - this.doc.source_view.buffer.notify["cursor-position"].disconnect (format_line_header); + public void set_document (Scratch.Services.Document set_doc) requires (set_doc != null) { + if (doc != null) { + doc.source_view.notify["language"].disconnect (update_current_lang); + doc.source_view.buffer.notify["cursor-position"].disconnect (format_line_header); } - this.doc = doc; + doc = set_doc; + + doc.source_view.notify["language"].connect (update_current_lang); update_current_lang (); - format_tab_header_from_global_settings (); + + doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); format_line_header (); - this.doc.source_view.buffer.notify["cursor-position"].connect (format_line_header); + + format_tab_header_from_global_settings (); } public void set_insert_spaces_instead_of_tabs (bool use_spaces) {