-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add a feature to toggle between panes in the core #10555 #12853
Changes from 10 commits
08a46b3
2f793e7
fc5a114
b092dea
0b63bc7
ce4350b
e099010
77a8f4b
4289bd5
8211931
40586ae
569698f
8823a85
567668a
77ee794
88b333e
717d13e
0848104
954f39c
8e5d581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,8 @@ define(function (require, exports, module) { | |
AsyncUtils = require("utils/Async"), | ||
ViewUtils = require("utils/ViewUtils"), | ||
Resizer = require("utils/Resizer"), | ||
Pane = require("view/Pane").Pane; | ||
Pane = require("view/Pane").Pane, | ||
KeyBindingManager = brackets.getModule("command/KeyBindingManager"); | ||
|
||
/** | ||
* Preference setting name for the MainView Saved State | ||
|
@@ -844,6 +845,35 @@ define(function (require, exports, module) { | |
return result.promise(); | ||
} | ||
|
||
/** | ||
* Switch between panes | ||
*/ | ||
function switchPaneFocus() { | ||
var $firstPane = $('#first-pane'), $secondPane = $('#second-pane'); | ||
if($firstPane.hasClass('active-pane')) { | ||
$secondPane.click(); | ||
} | ||
else { | ||
$firstPane.click(); | ||
} | ||
} | ||
|
||
/** | ||
* Unit test for switching from first pane to second pane | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @petetnt I'm having trouble simulating 'Alt-w' key press using SpecRunnerUtils.simulateKeyEvent. Here is my attempt: SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_ALT, "keydown", `$('#first-pane')[0]); Could you please let me know what I'm doing wrong? Thank you so much! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arthur801031 Dang, I remembered that SimulateKeyEvent has modifier keys support but it seems not: https://github.com/adobe/brackets/blob/master/test/spec/SpecRunnerUtils.js#L998 Let's modify the tests so that you use Sorry for the extra trouble. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @petetnt So we don't check whether or not 'Alt-W' is pressed? We only check if cmd.switchPaneFocus can actually switch pane between first pane and second pane. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arthur801031 exactly. I created an issue for adding the modifier key option #12859 |
||
*/ | ||
function switchPaneUnitTest1To2() { | ||
var $firstPane = $('#first-pane'); | ||
$firstPane.click(); | ||
KeyBindingManager._handleKey('Alt-W'); | ||
} | ||
|
||
/** | ||
* Unit test for switching from second pane to first pane | ||
*/ | ||
function switchPaneUnitTest2To1() { | ||
KeyBindingManager._handleKey('Alt-W'); | ||
} | ||
|
||
/** | ||
* DocumentManager.pathDeleted Event handler to remove a file | ||
* from the MRU list | ||
|
@@ -1616,6 +1646,10 @@ define(function (require, exports, module) { | |
// get an event handler for workspace events and we don't listen | ||
// to the event before we've been initialized | ||
WorkspaceManager.on("workspaceUpdateLayout", _updateLayout); | ||
|
||
// Listen to key Alt-W to toggle between panes | ||
CommandManager.register(Strings.CMD_SWITCH_PANE_FOCUS, Commands.CMD_SWITCH_PANE_FOCUS, switchPaneFocus); | ||
KeyBindingManager.addBinding(Commands.CMD_SWITCH_PANE_FOCUS, {key: 'Alt-W'}); | ||
} | ||
|
||
/** | ||
|
@@ -1658,8 +1692,8 @@ define(function (require, exports, module) { | |
|
||
return result; | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this change as it's only unintentional whitespace modification. |
||
/** | ||
* Setup a ready event to initialize ourself | ||
*/ | ||
|
@@ -1729,6 +1763,9 @@ define(function (require, exports, module) { | |
|
||
exports.getAllOpenFiles = getAllOpenFiles; | ||
exports.focusActivePane = focusActivePane; | ||
exports.switchPaneFocus = switchPaneFocus; | ||
exports.switchPaneUnitTest1To2 = switchPaneUnitTest1To2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, see above |
||
exports.switchPaneUnitTest2To1 = switchPaneUnitTest2To1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, see above |
||
|
||
// Layout | ||
exports.setLayoutScheme = setLayoutScheme; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -536,6 +536,31 @@ define(function (require, exports, module) { | |
expect(MainViewManager.getLayoutScheme()).toEqual({rows: 1, columns: 1}); | ||
}); | ||
}); | ||
it("should switch pane when alt-w is pressed", function () { | ||
runs(function () { | ||
MainViewManager.setLayoutScheme(1, 2); | ||
}); | ||
runs(function () { | ||
MainViewManager.switchPaneUnitTest1To2(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above for my comment on how to handle these; the tests are valid but they test if |
||
expect(MainViewManager.getActivePaneId()).toEqual("second-pane"); | ||
}); | ||
runs(function () { | ||
MainViewManager.switchPaneUnitTest2To1(); | ||
expect(MainViewManager.getActivePaneId()).toEqual("first-pane"); | ||
}); | ||
|
||
runs(function () { | ||
MainViewManager.setLayoutScheme(2, 1); | ||
}); | ||
runs(function () { | ||
MainViewManager.switchPaneUnitTest1To2(); | ||
expect(MainViewManager.getActivePaneId()).toEqual("second-pane"); | ||
}); | ||
runs(function () { | ||
MainViewManager.switchPaneUnitTest2To1(); | ||
expect(MainViewManager.getActivePaneId()).toEqual("first-pane"); | ||
}); | ||
}); | ||
it("should activate pane when editor gains focus", function () { | ||
var editors = {}, | ||
handler = function (e, doc, editor, paneId) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs rebase against master so we don't have these duplicate files,
git fetch upstream master && git rebase upstream/master
.