mirror of
https://github.com/atom/atom.git
synced 2026-01-22 13:28:01 -05:00
Use actual indentation length when setting indentation for row.
Closes #1293
This commit is contained in:
@@ -2722,6 +2722,15 @@ describe "Editor", ->
|
||||
editor.moveCursorLeft()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
|
||||
|
||||
describe ".setIndentationForBufferRow", ->
|
||||
describe "when the editor uses soft tabs but the row has hard tabs", ->
|
||||
it "only replaces whitespace charachters", ->
|
||||
editor.setSoftWrap(true)
|
||||
editor.setText(" 1\n 2")
|
||||
editor.setCursorBufferPosition([0, 0])
|
||||
editor.setIndentationForBufferRow(0, 2)
|
||||
expect(editor.getText()).toBe(" 1\n 2")
|
||||
|
||||
describe "when the editor's grammar has an injection selector", ->
|
||||
beforeEach ->
|
||||
atom.packages.activatePackage('language-text', sync: true)
|
||||
|
||||
@@ -269,10 +269,9 @@ class Editor extends Model
|
||||
# * newLevel:
|
||||
# A {Number} indicating the new indentation level.
|
||||
setIndentationForBufferRow: (bufferRow, newLevel) ->
|
||||
currentLevel = @indentationForBufferRow(bufferRow)
|
||||
currentIndentString = @buildIndentString(currentLevel)
|
||||
currentIndentLength = @lineForBufferRow(bufferRow).match(/^\s*/)[0].length
|
||||
newIndentString = @buildIndentString(newLevel)
|
||||
@buffer.change([[bufferRow, 0], [bufferRow, currentIndentString.length]], newIndentString)
|
||||
@buffer.change([[bufferRow, 0], [bufferRow, currentIndentLength]], newIndentString)
|
||||
|
||||
# Public: Returns the indentation level of the given line of text.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user