From 61600fcdf156c77628ec49bf770a9e75dc658c79 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 8 Jan 2013 17:12:08 -0800 Subject: [PATCH] Reload grammar with edit session path changes --- spec/app/editor-spec.coffee | 7 ++++++- src/app/editor.coffee | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index d075fdae9..1bc865754 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -502,6 +502,11 @@ describe "Editor", -> editor.getBuffer().saveAs("/tmp/atom-new.txt") expect(eventHandler).toHaveBeenCalled() + it "loads the grammar for the new path", -> + expect(editor.getGrammar().name).toBe 'JavaScript' + editor.getBuffer().saveAs(path) + expect(editor.getGrammar().name).toBe 'Plain Text' + describe "font size", -> it "sets the initial font size based on the value from config", -> config.set("editor.fontSize", 20) @@ -2091,7 +2096,7 @@ describe "Editor", -> expect(editor.getEditSessions().length).toBe 0 describe ".reloadGrammar()", -> - path = [] + [path] = [] beforeEach -> path = "/tmp/grammar-change.txt" diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 5cf576a29..9a3d38f25 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -505,6 +505,7 @@ class Editor extends View @showBufferConflictAlert(@activeEditSession) @activeEditSession.on "path-changed.editor", => + @reloadGrammar() @trigger 'editor:path-changed' @trigger 'editor:path-changed'