Merge branch 'master' of github.com:github/atom

This commit is contained in:
Nathan Sobo
2012-06-05 12:48:16 -06:00
4 changed files with 19 additions and 5 deletions

View File

@@ -2127,6 +2127,14 @@ describe "Editor", ->
expect(editor.renderedLines.find('.line:eq(2)')).toHaveHtml ' '
expect(editor.getCursorScreenPosition()).toEqual(row: 2, column: 0)
describe "insert-newline-below", ->
it "inserts a newline below the cursor, autoindents it, and moves the cursor to the end of the line", ->
editor.autoIndent = true
editor.trigger "newline-below"
expect(editor.buffer.lineForRow(0)).toBe "var quicksort = function () {"
expect(editor.buffer.lineForRow(1)).toBe " "
expect(editor.getCursorBufferPosition()).toEqual [1,2]
describe "backspace", ->
describe "when the cursor is on the middle of the line", ->
it "removes the character before the cursor", ->

View File

@@ -105,6 +105,7 @@ class Editor extends View
'select-up': @selectUp
'select-down': @selectDown
'newline': @insertNewline
'newline-below': @insertNewlineBelow
'tab': @insertTab
'indent-selected-rows': @indentSelectedRows
'outdent-selected-rows': @outdentSelectedRows
@@ -702,6 +703,10 @@ class Editor extends View
insertNewline: ->
@insertText('\n')
insertNewlineBelow: ->
@moveCursorToEndOfLine()
@insertNewline()
insertTab: ->
if @getSelection().isEmpty()
if @softTabs

View File

@@ -5,9 +5,10 @@ window.keymap.bindKeys '.editor',
'shift-up': 'select-up'
'shift-down': 'select-down'
'meta-a': 'select-all'
enter: 'newline'
tab: 'tab'
backspace: 'backspace'
'enter': 'newline'
'meta-enter': 'newline-below'
'tab': 'tab'
'backspace': 'backspace'
'delete': 'delete'
'meta-x': 'cut'
'meta-c': 'copy'

View File

@@ -108,10 +108,10 @@ class Selection extends View
{ text, shouldOutdent } = @autoIndentText(text)
oldBufferRange = @getBufferRange()
@editor.destroyFoldsContainingBufferRow(oldBufferRange.end.row)
isReversed = @isReversed()
wasReversed = @isReversed()
@clearSelection()
newBufferRange = @editor.buffer.change(oldBufferRange, text)
@cursor.setBufferPosition(newBufferRange.end, skipAtomicTokens: true) if isReversed
@cursor.setBufferPosition(newBufferRange.end, skipAtomicTokens: true) if wasReversed
@autoOutdentText() if shouldOutdent
indentSelectedRows: ->