Add ctrl-Z keybinding to checkout HEAD revision

This commit is contained in:
Kevin Sawicki
2012-11-03 15:50:11 -07:00
parent 55d77eea8b
commit 830a0b337a
5 changed files with 48 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ CursorView = require 'cursor-view'
SelectionView = require 'selection-view'
Native = require 'native'
fs = require 'fs'
Git = require 'git'
$ = require 'jquery'
_ = require 'underscore'
@@ -154,6 +154,7 @@ class Editor extends View
'editor:show-previous-buffer': @loadPreviousEditSession
'editor:toggle-line-comments': @toggleLineCommentsInSelection
'editor:log-cursor-scope': @logCursorScope
'editor:checkout-head-revision': @checkoutHead
documentation = {}
for name, method of editorBindings
@@ -274,6 +275,11 @@ class Editor extends View
setInvisibles: (@invisibles={}) ->
@renderLines()
checkoutHead: ->
if path = @getPath()
if new Git(path).checkoutHead(path)
@trigger 'editor-git-status-change'
setText: (text) -> @getBuffer().setText(text)
getText: -> @getBuffer().getText()
getPath: -> @getBuffer().getPath()

View File

@@ -0,0 +1,2 @@
window.keymap.bindKeys '.editor',
'ctrl-Z': 'editor:checkout-head-revision'

View File

@@ -40,6 +40,8 @@ class StatusBar extends View
@updateCursorPositionText()
@editor.on 'cursor-move', => _.delay (=> @updateCursorPositionText()), 50
@editor.on 'editor-git-status-change', => @updateStatusBar()
@subscribeToBuffer()
subscribeToBuffer: ->