mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
Hitting tab on a line (containing only whitespace) will auto indent the line and set the cursor to the end
This commit is contained in:
@@ -131,7 +131,12 @@ class EditSession
|
||||
|
||||
insertTab: ->
|
||||
if @getSelection().isEmpty()
|
||||
if @softTabs
|
||||
whitespaceMatch = @lineForBufferRow(@getCursorBufferPosition().row).match /^\s*$/
|
||||
if @autoIndent and whitespaceMatch
|
||||
indentation = @indentationForRow(@getCursorBufferPosition().row)
|
||||
@getSelection().selectLine()
|
||||
@insertText(indentation)
|
||||
else if @softTabs
|
||||
@insertText(@tabText)
|
||||
else
|
||||
@insertText('\t')
|
||||
@@ -225,6 +230,9 @@ class EditSession
|
||||
largestFoldStartingAtScreenRow: (screenRow) ->
|
||||
@displayBuffer.largestFoldStartingAtScreenRow(screenRow)
|
||||
|
||||
indentationForRow: (row) ->
|
||||
@tokenizedBuffer.indentationForRow(row)
|
||||
|
||||
autoIndentTextAfterBufferPosition: (text, bufferPosition) ->
|
||||
return { text } unless @autoIndent
|
||||
@tokenizedBuffer.autoIndentTextAfterBufferPosition(text, bufferPosition)
|
||||
|
||||
@@ -48,6 +48,11 @@ class TokenizedBuffer
|
||||
else
|
||||
null
|
||||
|
||||
indentationForRow: (row) ->
|
||||
state = @stateForRow(row)
|
||||
previousRowText = @buffer.lineForRow(row - 1)
|
||||
@aceMode.getNextLineIndent(state, previousRowText, @tabText)
|
||||
|
||||
autoIndentTextAfterBufferPosition: (text, bufferPosition) ->
|
||||
{ row, column} = bufferPosition
|
||||
state = @stateForRow(row)
|
||||
|
||||
Reference in New Issue
Block a user