mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
meta-{ goes to previous buffer
This commit is contained in:
@@ -2097,8 +2097,7 @@ describe "Editor", ->
|
||||
editor.buffer.setPath("new.txt")
|
||||
expect(eventHandler).toHaveBeenCalled()
|
||||
|
||||
|
||||
fdescribe ".loadNextEditorState()", ->
|
||||
describe ".loadNextEditorState()", ->
|
||||
it "loads the next editor state and wraps to beginning when end is reached", ->
|
||||
buffer0 = new Buffer("0")
|
||||
buffer1 = new Buffer("1")
|
||||
@@ -2114,3 +2113,20 @@ describe "Editor", ->
|
||||
expect(editor.buffer.path).toBe "1"
|
||||
editor.loadNextEditorState()
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
|
||||
describe ".loadPreviousEditorState()", ->
|
||||
it "loads the next editor state and wraps to beginning when end is reached", ->
|
||||
buffer0 = new Buffer("0")
|
||||
buffer1 = new Buffer("1")
|
||||
buffer2 = new Buffer("2")
|
||||
editor = new Editor {buffer: buffer0}
|
||||
editor.setBuffer(buffer1)
|
||||
editor.setBuffer(buffer2)
|
||||
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
editor.loadPreviousEditorState()
|
||||
expect(editor.buffer.path).toBe "1"
|
||||
editor.loadPreviousEditorState()
|
||||
expect(editor.buffer.path).toBe "0"
|
||||
editor.loadPreviousEditorState()
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
|
||||
@@ -85,6 +85,7 @@ class Editor extends View
|
||||
@on 'split-down', => @splitDown()
|
||||
@on 'close', => @remove(); false
|
||||
@on 'show-next-buffer', => @loadNextEditorState()
|
||||
@on 'show-previous-buffer', => @loadPreviousEditorState()
|
||||
|
||||
@on 'move-to-top', => @moveCursorToTop()
|
||||
@on 'move-to-bottom', => @moveCursorToBottom()
|
||||
@@ -251,6 +252,12 @@ class Editor extends View
|
||||
nextIndex = (index + 1) % @editorStates.length
|
||||
@setEditorState(@editorStates[nextIndex])
|
||||
|
||||
loadPreviousEditorState: ->
|
||||
index = @indexOfEditorState(@getEditorState())
|
||||
if index?
|
||||
previousIndex = if --index >= 0 then index else @editorStates.length - 1
|
||||
@setEditorState(@editorStates[previousIndex])
|
||||
|
||||
setEditorState: (editorState={}) ->
|
||||
buffer = editorState.buffer ?= new Buffer
|
||||
@setEditorStateForBuffer(buffer, editorState)
|
||||
|
||||
@@ -31,4 +31,5 @@ window.keymap.bindKeys '.editor',
|
||||
'alt-meta-down': 'split-down'
|
||||
'meta-[': 'outdent-selected-rows'
|
||||
'meta-]': 'indent-selected-rows'
|
||||
'meta-{': 'show-previous-buffer'
|
||||
'meta-}': 'show-next-buffer'
|
||||
Reference in New Issue
Block a user