This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Close Others extension improvements. #5497
Closed
Closed
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
eaa593b
'clearCurrentDoc' flag added to '_doCloseDocumentList'
sathyamoorthi 7ff5efa
unit test file update
sathyamoorthi 913cabc
Add / remove context menus at run time.
sathyamoorthi 05e41ef
jsHint fixes.
sathyamoorthi d0fa2db
replace `jQuery` with `$` for coding standard.
sathyamoorthi 83d603c
Code changes proposed by Jeff and Ian
sathyamoorthi e1efd6d
Tab alignments corrected.
sathyamoorthi fbdd877
Test file updated to match standards.
sathyamoorthi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,16 +126,25 @@ define(function (require, exports, module) { | |
|
||
function runCloseOthers() { | ||
var ws = DocumentManager.getWorkingSet(), | ||
e = new $.Event("contextmenu"), | ||
promise; | ||
|
||
if (ws.length > docSelectIndex) { | ||
DocumentManager.getDocumentForPath(ws[docSelectIndex].fullPath).done(function (doc) { | ||
DocumentManager.setCurrentDocument(doc); | ||
|
||
e.pageX = 20; | ||
e.pageY = 20; | ||
$("#open-files-container").trigger(e); | ||
}); | ||
|
||
promise = CommandManager.execute(cmdToRun); | ||
waitsForDone(promise, cmdToRun); | ||
} | ||
|
||
runs(function () { | ||
expect(DocumentManager.getCurrentDocument()).not.toBe(null); | ||
}); | ||
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. this tab is misaligned |
||
} | ||
|
||
it("Close others", function () { | ||
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. can you fix the tabs in this block. lines 156-159 are misaligned 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. This is funny issue. It looked good in Brackets and Submlime but not in github. I deleted and recreated those lines to fix this. |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
do you need to specify mouse coordinates here? If I change them to 0,0 or 500,500 does it still work or is 20,20 the only thing that works? We may want to think about a different way to exercise the handler -- using page relative mouse clicks to invoke a menu is bad. @redmunds -- do you have an opinion on this?
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 need to trigger "contextmenu" event on "working set" to open context menu popup. So only context menus (Close Others / Above / Below) will get populate. Without specifying coordinates,
Menu.js
gives me an error fromline 960
. But coordinates can be anything.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 think this logic depends on the context menu being displayed at 0,0 of page and context menu item being at 20,20. I agree with @JeffryBooher that it's fragile and unnecessary to test this. Instead you can use
closeOthers = require("main")
to include your module and call thehandleClose()
function directly. Note: you'll need to export it as something like_handleClose
to indicate it's only meant to be public for unit testing.Related comment: I notice that this extension only displays the "Close Others" command in the context menu when there's more than 1 item in the Working Set. I prefer to always have commands shown and then disable them appropriately. I mention this, because this test depends on context menu item being in a particular position, yet this extension makes this indeterminate for other code.
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.
@JeffryBooher @redmunds
_I notice that this extension only displays the "Close Others" command in the context menu when there's more than 1 item in the Working Set. I prefer to always have commands shown and then disable them appropriately_
disable Or remove? Currently it removes unnecessary Or shows necessary "Context Menu Items" based on user file selection as like below screenshot. If we show all 3 all time and if we only disable them (as like in Google Chrome Tabs), context menu would look like lengthy in Brackets.
_I think this logic depends on the context menu being displayed at 0,0 of page and context menu item being at 20,20._
Nope. we can specify like below, which means coordinates can be anything.
This extension removes unnecessary menus Or adds necessary menus on workingset's
beforeContextMenuOpen
event. For that, i need to open "Context Menu Popup" before run my tests. So only appropriate "Context Menu Items" will get populate. But clearly this is test is not dealing with "Context Menu" position._using page relative mouse clicks to invoke a menu is bad._
:) why? Test file's intention is to open a context menu, not open it at particular position. And if you still think, this hack would cause an error in future, it is just a test file. At maximum, tests would fail. It won't affect Brackets.
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.
If value of
e.pageX
ande.pageY
can be anything, then use -1,-1 or 0,0 and add a comment that explains value doesn't matter.