From 0120df540afce7c083d3ca27cd6460117da12fe2 Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Thu, 2 Feb 2012 17:04:37 -0700 Subject: [PATCH] Lines remain syntax-highlighted when they are updated. --- spec/atom/editor-spec.coffee | 6 ++++++ src/atom/editor.coffee | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index 8ecb1ab47..c7707e076 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -39,6 +39,12 @@ describe "Editor", -> line12 = editor.lines.find('.line:eq(11)') expect(line12.find('span:eq(1)')).toMatchSelector '.keyword' + describe "when lines are updated in the buffer", -> + it "syntax highlights the updated lines", -> + expect(editor.lines.find('.line:eq(0) span:eq(0)')).toMatchSelector '.keyword.definition' + buffer.insert([0, 4], "g") + expect(editor.lines.find('.line:eq(0) span:eq(0)')).toMatchSelector '.keyword.definition' + describe "cursor movement", -> describe ".setCursorPosition({row, column})", -> beforeEach -> diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index e2428eda8..86eded41a 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -133,12 +133,7 @@ class Editor extends Template @cursor.bufferChanged(e) updateLineElement: (row) -> - line = @buffer.getLine(row) - element = @getLineElement(row) - if line == '' - element.html(' ') - else - element.text(line) + @getLineElement(row).replaceWith(@buildLineElement(row)) insertLineElement: (row) -> @getLineElement(row).before(@buildLineElement(row))