mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
Merge branch 'master' of github.com:github/atom
This commit is contained in:
@@ -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", ->
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user