Skip to content
This repository has been archived by the owner on Apr 6, 2018. It is now read-only.

Make removes safe for normal-mode-input-element (fixes #713) #1092

Closed
wants to merge 2 commits into from
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
2 changes: 1 addition & 1 deletion lib/view-models/view-model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ViewModel
{@editor, @vimState} = @operation
@view = new VimNormalModeInputElement().initialize(this, atom.views.getView(@editor), opts)
@editor.normalModeInputView = @view
@vimState.onDidFailToCompose => @view.remove()
@vimState.onDidFailToCompose => @view.safeRemove()

confirm: (view) ->
@vimState.pushOperations(new Input(@view.value))
Expand Down
11 changes: 10 additions & 1 deletion lib/view-models/vim-normal-mode-input-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ class VimNormalModeInputElement extends HTMLDivElement
if @panel?
@panel.destroy()
else
this.remove()
@safeRemove()

safeRemove: ->
# A combination of @confirm, the blur event (@cancel), and @viewModel's
# onDidFailToCompose handler can result in redundant calls to remove this
# element. Only call this.remove on the first such request
return if @removed
@removed = true
this.remove()


module.exports =
document.registerElement("vim-normal-mode-input"
Expand Down