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

Add a feature to toggle between panes in the core #10555 #12853

Merged
merged 20 commits into from
Oct 28, 2016

Conversation

arthur801031
Copy link
Contributor

  • I'm not sure if I need to add a menu item for this feature inside "Navigate".
  • I'm also not sure if I placed the code inside the correct files since I'm new to open source project contributions.

Thank you!

@swmitra
Copy link
Collaborator

swmitra commented Oct 26, 2016

@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",
Copy link
Collaborator

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?

Copy link
Contributor Author

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",

Copy link
Collaborator

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 ?

Copy link
Collaborator

@petetnt petetnt Oct 26, 2016

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() {
Copy link
Collaborator

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.

Copy link
Contributor Author

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;
}



Copy link
Collaborator

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");
Copy link
Collaborator

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.

@arthur801031
Copy link
Contributor Author

arthur801031 commented Oct 27, 2016

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.
screen shot 2016-10-27 at 9 57 37 am
I was also having this problem before I started editing any files.

Here is my Brackets version:
screen shot 2016-10-27 at 10 00 12 am

Here is the Developer Tools' Console output:
screen shot 2016-10-27 at 10 40 18 am

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:
screen shot 2016-10-27 at 11 21 56 am

@swmitra swmitra added this to the Release 1.9 milestone Oct 27, 2016
@petetnt
Copy link
Collaborator

petetnt commented Oct 27, 2016

@arthur801031 Did you run git submodule update --init too?

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.

@arthur801031
Copy link
Contributor Author

@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!

@arthur801031
Copy link
Contributor Author

@petetnt @swmitra
I figured out how to get Jasmine Spec Runner to run. Here is what I did:

  1. I used npm install chokidar --save to install chokidar since I was missing the code from chokidar.
  2. I used npm install acorn to install acorn since I was missing this as well.
  3. There were error messages saying that it's looking for 'acorn' in '/Users/i-chun/Documents/brackets/src/extensions/default/JavaScriptCodeHints', so I created a folder named 'node_modules' and put 'acorn' folder inside this directory.
  4. There was also an error message saying that it's looking for 'acorn' in '/Users/i-chun/Documents/brackets/test', so I created a folder named 'node_modules' and put 'acorn' folder inside this directory.

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!

@zaggino
Copy link
Contributor

zaggino commented Oct 27, 2016

That's weird @arthur801031 , the dependencies you mentioned are already in package.json file. Didn't just npm install install them for you?

@arthur801031
Copy link
Contributor Author

@zaggino I think I ran npm install before, but I'm not 100% sure. But, in my previous comment's bullet point 3, it seemed that 'HintUtils.js', 'main.js', 'Session.js' were looking for 'node_modules/acorn' in their currernt folder, since that folder was not there the Jasmine Spec Runner crash.

@arthur801031
Copy link
Contributor Author

@petetnt @swmitra

The feature and the test function for this feature are now working correctly. I'm not sure why the check has failed for this commit. Please help. Thank you!

Copy link
Collaborator

@petetnt petetnt left a 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",
Copy link
Collaborator

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
Copy link
Collaborator

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

Copy link
Contributor Author

@arthur801031 arthur801031 Oct 28, 2016

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!

Copy link
Collaborator

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. 👍

Copy link
Contributor Author

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.

Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

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();
Copy link
Collaborator

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 ^^

@petetnt petetnt changed the title Added a feature to toggle between panes in the core as requested by @petetnt in issues #10555 Added a feature to toggle between panes in the core #10555 Oct 28, 2016
@petetnt petetnt changed the title Added a feature to toggle between panes in the core #10555 Add a feature to toggle between panes in the core #10555 Oct 28, 2016
@arthur801031
Copy link
Contributor Author

@petetnt I finished/uploaded the test and rebased against master branch. Please review my code again. Thank you so much! :)

@petetnt
Copy link
Collaborator

petetnt commented Oct 28, 2016

This LGTM, all tests passing. Merging this, thanks a lot @arthur801031, hopefully you'll contribute to Brackets in the future too!

@swmitra
Copy link
Collaborator

swmitra commented Oct 28, 2016

Great work @arthur801031 and @petetnt in closing this PR 👍

@schroef
Copy link

schroef commented Mar 24, 2017

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
found them, http://apple.stackexchange.com/questions/55727/where-can-i-find-the-unicode-symbols-for-mac-functional-keys-command-shift-e

@swmitra
Copy link
Collaborator

swmitra commented Mar 24, 2017

If I remember correctly it's Ctrl+w. @Petent Can you please confirm?

@petetnt
Copy link
Collaborator

petetnt commented Mar 24, 2017

It's Alt+W 👍

@schroef
Copy link

schroef commented Mar 24, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants