mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Root view can receive focus if there is no active editor.
This allows basic key bindings to work without an editor.
This commit is contained in:
parent
4c74e2187d
commit
49be6986a0
@ -33,6 +33,21 @@ describe "RootView", ->
|
||||
rootView = new RootView
|
||||
expect(rootView.activeEditor().buffer.url).toBeUndefined()
|
||||
|
||||
describe "focus", ->
|
||||
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
|
||||
rootView = new RootView(require.resolve 'fixtures')
|
||||
rootView.attachToDom()
|
||||
expect(rootView).toMatchSelector(':focus')
|
||||
|
||||
rootView.activeEditor() # lazily create an editor
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
|
||||
rootView.focus()
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.activeEditor().isFocused).toBeTruthy()
|
||||
|
||||
|
||||
describe "split editor panes", ->
|
||||
editor1 = null
|
||||
|
||||
|
@ -13,7 +13,7 @@ CommandPanel = require 'command-panel'
|
||||
module.exports =
|
||||
class RootView extends View
|
||||
@content: ->
|
||||
@div id: 'root-view', =>
|
||||
@div id: 'root-view', tabindex: -1, =>
|
||||
@div id: 'panes', outlet: 'panes'
|
||||
|
||||
editors: null
|
||||
@ -32,6 +32,12 @@ class RootView extends View
|
||||
@on 'toggle-file-finder', => @toggleFileFinder()
|
||||
@on 'show-console', -> window.showConsole()
|
||||
|
||||
@one 'attach', => @focus()
|
||||
@on 'focus', (e) =>
|
||||
if @editors.length
|
||||
@activeEditor().focus()
|
||||
false
|
||||
|
||||
@commandPanel = new CommandPanel({rootView: this})
|
||||
|
||||
createProject: (path) ->
|
||||
|
Loading…
Reference in New Issue
Block a user