mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Merge branch 'master' into global-find
This commit is contained in:
@@ -124,9 +124,17 @@ class EditSession
|
||||
@moveCursorToEndOfLine()
|
||||
@insertNewline()
|
||||
|
||||
insertTab: ->
|
||||
indent: ->
|
||||
if @getSelection().isEmpty()
|
||||
if @softTabs
|
||||
whitespaceMatch = @lineForBufferRow(@getCursorBufferPosition().row).match /^\s*$/
|
||||
if @autoIndent and whitespaceMatch
|
||||
indentation = @indentationForRow(@getCursorBufferPosition().row)
|
||||
if indentation.length > whitespaceMatch[0].length
|
||||
@getSelection().selectLine()
|
||||
@insertText(indentation)
|
||||
else
|
||||
@insertText(@tabText)
|
||||
else if @softTabs
|
||||
@insertText(@tabText)
|
||||
else
|
||||
@insertText('\t')
|
||||
@@ -220,6 +228,9 @@ class EditSession
|
||||
largestFoldStartingAtScreenRow: (screenRow) ->
|
||||
@displayBuffer.largestFoldStartingAtScreenRow(screenRow)
|
||||
|
||||
indentationForRow: (row) ->
|
||||
@tokenizedBuffer.indentationForRow(row)
|
||||
|
||||
autoIndentTextAfterBufferPosition: (text, bufferPosition) ->
|
||||
return { text } unless @autoIndent
|
||||
@tokenizedBuffer.autoIndentTextAfterBufferPosition(text, bufferPosition)
|
||||
|
||||
@@ -105,7 +105,7 @@ class Editor extends View
|
||||
'select-down': @selectDown
|
||||
'select-word': @selectWord
|
||||
'newline': @insertNewline
|
||||
'tab': @insertTab
|
||||
'indent': @indent
|
||||
'indent-selected-rows': @indentSelectedRows
|
||||
'outdent-selected-rows': @outdentSelectedRows
|
||||
'backspace': @backspace
|
||||
@@ -211,7 +211,7 @@ class Editor extends View
|
||||
insertText: (text) -> @activeEditSession.insertText(text)
|
||||
insertNewline: -> @activeEditSession.insertNewline()
|
||||
insertNewlineBelow: -> @activeEditSession.insertNewlineBelow()
|
||||
insertTab: -> @activeEditSession.insertTab()
|
||||
indent: -> @activeEditSession.indent()
|
||||
indentSelectedRows: -> @activeEditSession.indentSelectedRows()
|
||||
outdentSelectedRows: -> @activeEditSession.outdentSelectedRows()
|
||||
cutSelection: -> @activeEditSession.cutSelectedText()
|
||||
|
||||
@@ -7,7 +7,7 @@ window.keymap.bindKeys '.editor',
|
||||
'meta-a': 'select-all'
|
||||
'enter': 'newline'
|
||||
'meta-enter': 'newline-below'
|
||||
'tab': 'tab'
|
||||
'tab': 'indent'
|
||||
'backspace': 'backspace'
|
||||
'delete': 'delete'
|
||||
'meta-x': 'cut'
|
||||
|
||||
@@ -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