From 27f44fbfd795b3d229e56affb9f0b0f92d2b26ee Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Feb 2013 16:36:13 -0800 Subject: [PATCH] Invalidate empty lines proceeding a change event The indent guide on empty lines will now be updated when the non-empty line preceeding the empty lines is updated. --- spec/app/editor-spec.coffee | 14 ++++++++++++++ src/app/editor.coffee | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index a41bbd7f1..d30a3b3f2 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -1849,6 +1849,20 @@ describe "Editor", -> expect(editor.renderedLines.find('.line:eq(12) .indent-guide').length).toBe 0 + describe "when the indentation level on a line before an empty line is changed", -> + it "updates the indent guide on the empty line", -> + editor.attachToDom() + config.set("editor.showIndentGuide", true) + + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').length).toBe 1 + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').text()).toBe ' ' + + editor.setCursorBufferPosition([9]) + editor.indentSelectedRows() + + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').length).toBe 2 + expect(editor.renderedLines.find('.line:eq(10) .indent-guide').text()).toBe ' ' + describe "gutter rendering", -> beforeEach -> editor.attachToDom(heightInLines: 5.5) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 47f676d89..dce44971e 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -1006,6 +1006,18 @@ class Editor extends View return [] if !@firstRenderedScreenRow? and !@lastRenderedScreenRow? intactRanges = [{start: @firstRenderedScreenRow, end: @lastRenderedScreenRow, domStart: 0}] + + if @showIndentGuide + trailingEmptyLineChanges = [] + for change in @pendingChanges + continue unless change.bufferDelta? + start = change.end + change.bufferDelta + 1 + continue unless @lineForBufferRow(start) is '' + end = start + end++ while @lineForBufferRow(end + 1) is '' + trailingEmptyLineChanges.push({start, end, screenDelta: 0}) + @pendingChanges.push(trailingEmptyLineChanges...) + for change in @pendingChanges newIntactRanges = [] for range in intactRanges