-
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
Conversation
@arthur801031 Can you please add/update some tests in MainViewManager test file? |
@@ -418,6 +418,7 @@ define({ | |||
"CMD_SHOW_IN_EXPLORER" : "Show in Explorer", | |||
"CMD_SHOW_IN_FINDER" : "Show in Finder", | |||
"CMD_SHOW_IN_OS" : "Show in OS", | |||
"CMD_SPLITVIEW_TOGGLE" : "Toggle Panes", |
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.
As this command is for shuffling focus across panes, can we name it accordingly?
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.
Can we write it like this?
"CMD_SHUFFLE_FOCUS_ACROSS_PANES" : "Shuffle Focus Across Panes",
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.
@petetnt What could be a suitable var name here ?
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.
Something like SWITCH_PANE_FOCUS
? 🚲 🏠
edit: changed from TOGGLE
as it sounds like on/off
@@ -209,6 +210,19 @@ define(function (require, exports, module) { | |||
} | |||
|
|||
/** | |||
* Toggle between panes | |||
*/ | |||
function _handleSwitchPane() { |
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.
This entire logic of shuffling focus across panes could be in MainViewManager. Pane should contain operations specific to creation, state mutation and handling other things inside a Pane. As this operation is a user requested focus preemption, it could be at a higher level above Panes.
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.
I will try moving this function to MainViewManager. Thank you!
@@ -1658,8 +1658,8 @@ define(function (require, exports, module) { | |||
|
|||
return result; | |||
} | |||
|
|||
|
|||
|
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.
Please revert this change as it's only unintentional whitespace modification.
@@ -167,6 +167,7 @@ define(function (require, exports, module) { | |||
ViewUtils = require("utils/ViewUtils"), | |||
ProjectManager = require("project/ProjectManager"), | |||
paneTemplate = require("text!htmlContent/pane.html"); | |||
var KeyBindingManager = brackets.getModule("command/KeyBindingManager"); |
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.
This var name declaration can be clubbed with the previous one.
Bumping version Number to 1.9
Hi @swmitra @petetnt , I'm having trouble using the Jasmine Spec Runner for unit tests. I go to Debug -> Run Tests and the content inside the Bracket Tests window is blank. I also can't close that window. It seems like it freezes. Here is the Developer Tools' Console output: And I'm using a 15 inch Macbook Pro and macOS Sierra Version 10.12.1. Please help. Thank you very much. Edit: @petetnt I saw your post #11773. It has the exact same behavior as the one your described. I also tried resetting cache & preferences. I just tried deleting all the files in the brackets folder and I cloned brackets.git from my account and followed the steps in "How to Hack on Brackets" to re-install the code. I'm now getting different error messages in the console: |
@arthur801031 Did you run It might be related to the spec runner window running out of memory and choking too and usually just restarting until it works works too. There's an issue tracking that too somewhere IIRC. If you have the tests at hand I can try running them too. |
…by petetnt and swmitra
…by petetnt and swmitra
@petetnt I tried restarting the program many times, but Jasmine Spec Runner is still blank. I just submitted the files with the unit test for this feature, but I've never written a unit test before, so I don't know if my code would work. Thank you! |
@petetnt @swmitra
Then, all the error messages in Jasmine Spec Runner's DevTools went away, and the Jasmine Spec Runner is now working correctly. Note: the unit test that I created for this feature does not work. I will try to modify it. Thank you! |
That's weird @arthur801031 , the dependencies you mentioned are already in |
@zaggino I think I ran |
…wManager-test.js and the test is now passing
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.
Made some comments about the tests. Feel free to ask extra instructions if needed 👍
"version": "1.8.0-0", | ||
"apiVersion": "1.8.0", | ||
"version": "1.9.0-0", | ||
"apiVersion": "1.9.0", |
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
.
} | ||
|
||
/** | ||
* Unit test for switching from first pane to second pane |
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.
We can use SpecRunnerUtils.simulateKeyEvent
instead; for examples see https://github.com/adobe/brackets/blob/f028b3ecdf2017498196f39ddbbe4a2364366c92/test/spec/InstallExtensionDialog-test.js and search for simulateKeyEvent
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.
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]);
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_W, "keydown", $('#first-pane')[0]);
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_W, "keypress", $('#first-pane')[0]);
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_W, "keyup", $('#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 comment
The 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 CommandManager.executeCommand
to run cmd.switchPaneFocus
and check that panes have switches after running that command.
Sorry for the extra trouble. 👍
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.
@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 comment
The 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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, see above
@@ -1729,6 +1763,9 @@ define(function (require, exports, module) { | |||
|
|||
exports.getAllOpenFiles = getAllOpenFiles; | |||
exports.focusActivePane = focusActivePane; | |||
exports.switchPaneFocus = switchPaneFocus; | |||
exports.switchPaneUnitTest1To2 = switchPaneUnitTest1To2; | |||
exports.switchPaneUnitTest2To1 = switchPaneUnitTest2To1; |
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.
Not needed, see above
MainViewManager.setLayoutScheme(1, 2); | ||
}); | ||
runs(function () { | ||
MainViewManager.switchPaneUnitTest1To2(); |
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.
See above for my comment on how to handle these; the tests are valid but they test if switchPaneUnitTest1To2
work, instead of testing if the keypress itself work ^^
…by petetnt and swmitra
…wManager-test.js and the test is now passing
@petetnt I finished/uploaded the test and rebased against master branch. Please review my code again. Thank you so much! :) |
This LGTM, all tests passing. Merging this, thanks a lot @arthur801031, hopefully you'll contribute to Brackets in the future too! |
Great work @arthur801031 and @petetnt in closing this PR 👍 |
SOrry for asking but what button is associated with this, tried google for the icon but cant seem to find it. On mac i need to use cmd+fn+ arrow up/down, my guess its page up/down. EDIT |
If I remember correctly it's Ctrl+w. @Petent Can you please confirm? |
It's Alt+W 👍 |
PS perhaps you should add a menu item for this. I noticed the new feature but it only tells us its possible now, doesnt say anything about the shortcut. I was actually mixing it up with switching documents, just know i understood that its for switching when 2 panes are active. |
Thank you!