From 36d55c93849950eebd568a798b0976336f3c2fc2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 8 Jun 2015 22:56:18 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20break=20out=20soft=20tabs=20tha?= =?UTF-8?q?t=20are=20interrupted=20by=20a=20scope=20boundary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/tokenized-buffer-spec.coffee | 16 ++++++++++++++++ src/tokenized-line.coffee | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/spec/tokenized-buffer-spec.coffee b/spec/tokenized-buffer-spec.coffee index dc57d3fee..23520518a 100644 --- a/spec/tokenized-buffer-spec.coffee +++ b/spec/tokenized-buffer-spec.coffee @@ -322,6 +322,22 @@ describe "TokenizedBuffer", -> expect(tokens[2].value).toBe " \u030b" expect(tokens[2].hasLeadingWhitespace()).toBe false + it "does not break out soft tabs across a scope boundary", -> + waitsForPromise -> + atom.packages.activatePackage('language-gfm') + + runs -> + tokenizedBuffer.setTabLength(4) + tokenizedBuffer.setGrammar(atom.grammars.selectGrammar('.md')) + buffer.setText(' 0 + + expect(length).toBe 4 + describe "when the buffer contains hard-tabs", -> beforeEach -> waitsForPromise -> diff --git a/src/tokenized-line.coffee b/src/tokenized-line.coffee index b8f7226c8..bd871fc4f 100644 --- a/src/tokenized-line.coffee +++ b/src/tokenized-line.coffee @@ -102,10 +102,11 @@ class TokenizedLine substringEnd += 1 else if (screenColumn + 1) % @tabLength is 0 - @specialTokens[tokenIndex] = SoftTab suffix = @tags[tokenIndex] - @tabLength - @tags.splice(tokenIndex, 1, @tabLength) - @tags.splice(tokenIndex + 1, 0, suffix) if suffix > 0 + if suffix >= 0 + @specialTokens[tokenIndex] = SoftTab + @tags.splice(tokenIndex, 1, @tabLength) + @tags.splice(tokenIndex + 1, 0, suffix) if suffix > 0 if @invisibles?.space if substringEnd > substringStart