Inserting a newline indents the cursor (based on information from previous line)

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-03-05 15:51:56 -08:00
parent 3ff8a1e92c
commit 53fc625534
2 changed files with 16 additions and 3 deletions

View File

@@ -300,7 +300,14 @@ class Editor extends View
selectToBufferPosition: (position) ->
@selection.selectToBufferPosition(position)
insertText: (text) -> @selection.insertText(text)
insertText: (text) ->
if text[0] == "\n"
tab = " "
state = @lineWrapper.lineForScreenRow(@getRow).state
indent = @buffer.mode.getNextLineIndent(state, @getCurrentLine(), tab)
text = text[0] + indent + text[1..]
@selection.insertText(text)
cutSelection: -> @selection.cut()
copySelection: -> @selection.copy()