Normalize all tabs, not just the first one

Refs atom/language-javascript#10
This commit is contained in:
Kevin Sawicki
2014-03-10 17:54:34 -07:00
parent a9becd5cc8
commit 86c720af81
2 changed files with 17 additions and 1 deletions

View File

@@ -2866,3 +2866,19 @@ describe "Editor", ->
{tokens} = editor.lineForScreenRow(0)
expect(tokens[2].value).toBe "SELECT"
expect(tokens[2].scopes).toEqual ["source.js", "comment.line.double-slash.js", "keyword.other.DML.sql"]
describe ".normalizeTabsInBufferRange()", ->
fit "normalizes tabs depending on the editor's soft tab/tab length settings", ->
editor.setTabLength(1)
editor.setSoftTabs(true)
editor.setText('\t\t\t')
editor.normalizeTabsInBufferRange([[0, 0], [0, 1]])
expect(editor.getText()).toBe ' \t\t'
editor.setTabLength(2)
editor.normalizeTabsInBufferRange([[0, 0], [Infinity, Infinity]])
expect(editor.getText()).toBe ' '
editor.setSoftTabs(false)
editor.normalizeTabsInBufferRange([[0, 0], [Infinity, Infinity]])
expect(editor.getText()).toBe ' '

View File

@@ -679,7 +679,7 @@ class Editor extends Model
# {Range}.
normalizeTabsInBufferRange: (bufferRange) ->
return unless @getSoftTabs()
@scanInBufferRange /\t/, bufferRange, ({replace}) => replace(@getTabText())
@scanInBufferRange /\t/g, bufferRange, ({replace}) => replace(@getTabText())
# Public: For each selection, if the selection is empty, cut all characters
# of the containing line following the cursor. Otherwise cut the selected