How to block a command?


#1

I have a type of editor tab that I don’t want to be able to split. Having two of this type is illogical and troublesome.

Can I block the split commands just when this type (class) of editor is showing?


#2

Does the split method trigger any before/after events by any chance? The Dev console should help there, although I haven’t tried using the events panel.


#3

It turned out to be easy. I did not realize commands were simply jquery events.

splitCommand = (e) =>
  atom.confirm
    message: 'Notice:\n'
    detailedMessage: 'You may not split a history view.'
    buttons: ['OK']
  e.stopPropagation()
  e.preventDefault()

@editorView.on 'pane:split-left',  splitCommand
@editorView.on 'pane:split-right', splitCommand
@editorView.on 'pane:split-up',    splitCommand
@editorView.on 'pane:split-down',  splitCommand

It doesn’t even show up in ctrl-shift-P and ctrl-K-up gives my message and blocks it.