Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/view-models/vim-command-mode-input-view.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{View, TextEditorView} = require 'atom'
{View, $} = require 'space-pen'
{TextEditorView} = require 'atom-space-pen-views'

module.exports =
class VimCommandModeInputView extends View
Expand All @@ -23,18 +24,20 @@ class VimCommandModeInputView extends View
@handleEvents()

handleEvents: ->
input = $ @editor[0].rootElement.querySelector 'input'
if @singleChar?
@editor.find('input').on 'textInput', @autosubmit
input.on 'textInput', @autosubmit
@editor.on 'core:confirm', @confirm
@editor.on 'core:cancel', @cancel
@editor.find('input').on 'blur', @cancel
input.on 'blur', @cancel

stopHandlingEvents: ->
input = $ @editor[0].rootElement.querySelector 'input'
if @singleChar?
@editor.find('input').off 'textInput', @autosubmit
input.off 'textInput', @autosubmit
@editor.off 'core:confirm', @confirm
@editor.off 'core:cancel', @cancel
@editor.find('input').off 'blur', @cancel
input.off 'blur', @cancel

autosubmit: (event) =>
@editor.setText(event.originalEvent.data)
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"atom": ">0.151.0"
},
"dependencies": {
"underscore-plus": "1.x",
"event-kit": "^0.7.2"
"atom-space-pen-views": "^2.0.4",
"event-kit": "^0.7.2",
"space-pen": "^5.1.1",
"underscore-plus": "1.x"
},
"consumedServices": {
"status-bar": {
Expand Down
2 changes: 1 addition & 1 deletion spec/motions-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe "Motions", ->
helpers.keydown(key, options)

commandModeInputKeydown = (key, opts = {}) ->
opts.element = editor.commandModeInputView.editor.find('input').get(0)
opts.element = helpers.getCommandModeInputElement editor
opts.raw = true
keydown(key, opts)

Expand Down
2 changes: 1 addition & 1 deletion spec/operators-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe "Operators", ->
helpers.keydown(key, options)

commandModeInputKeydown = (key, opts = {}) ->
opts.element = editor.commandModeInputView.editor.find('input').get(0)
opts.element = helpers.getCommandModeInputElement editor
opts.raw = true
keydown(key, opts)

Expand Down
11 changes: 10 additions & 1 deletion spec/spec-helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@ keydown = (key, {element, ctrl, shift, alt, meta, raw}={}) ->
element.value += key
dispatchKeyboardEvent(element, 'keyup', eventArgs...)

module.exports = { keydown, getEditorElement, mockPlatform, unmockPlatform }
getCommandModeInputElement = (editor) ->
editor.commandModeInputView.editor[0].rootElement.querySelector 'input'

module.exports = {
keydown
getCommandModeInputElement
getEditorElement
mockPlatform
unmockPlatform
}
2 changes: 1 addition & 1 deletion spec/text-objects-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe "TextObjects", ->
helpers.keydown(key, options)

commandModeInputKeydown = (key, opts = {}) ->
opts.element = editor.commandModeInputView.editor.find('input').get(0)
opts.element = helpers.getCommandModeInputElement editor
opts.raw = true
keydown(key, opts)

Expand Down
2 changes: 1 addition & 1 deletion spec/vim-state-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe "VimState", ->
helpers.keydown(key, options)

commandModeInputKeydown = (key, opts = {}) ->
opts.element = editor.commandModeInputView.editor.find('input').get(0)
opts.element = helpers.getCommandModeInputElement editor
opts.raw = true
keydown(key, opts)

Expand Down