From 1223d7a15474e1265fdb1dd9406d2f60f7774229 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 11 Aug 2015 13:13:30 -0600 Subject: [PATCH] Process closing scopes at wrap boundaries --- spec/display-buffer-spec.coffee | 7 +++++++ src/tokenized-line.coffee | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spec/display-buffer-spec.coffee b/spec/display-buffer-spec.coffee index 0da83d7e4..1b490d2ff 100644 --- a/spec/display-buffer-spec.coffee +++ b/spec/display-buffer-spec.coffee @@ -112,6 +112,13 @@ describe "DisplayBuffer", -> expect(displayBuffer.tokenizedLineForScreenRow(2).text).toBe 'uvwxyz' expect(displayBuffer.tokenizedLineForScreenRow(2).bufferDelta).toBe 'uvwxyz'.length + it "closes all scopes at the wrap boundary", -> + displayBuffer.setEditorWidthInChars(10) + buffer.setText("`aaa${1+2}aaa`") + iterator = displayBuffer.tokenizedLineForScreenRow(1).getTokenIterator() + scopes = iterator.getScopes() + expect(scopes[scopes.length - 1]).not.toBe 'punctuation.section.embedded.js' + describe "when there is a whitespace character at the max length boundary", -> it "wraps the line at the first non-whitespace character following the boundary", -> expect(displayBuffer.tokenizedLineForScreenRow(3).text).toBe ' var pivot = items.shift(), current, left = [], ' diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index bd871fc4f..bf234b6d3 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -387,15 +387,17 @@ class TokenizedLine rightSpecialTokens[rightTags.length] = specialToken rightTags.push(tag) - # tag represents the start or end of a scop + # tag represents the start of a scope else if (tag % 2) is -1 if screenColumn < column leftTags.push(tag) rightOpenScopes.push(tag) else rightTags.push(tag) + + # tag represents the end of a scope else - if screenColumn < column + if screenColumn <= column leftTags.push(tag) rightOpenScopes.pop() else