-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sash double clicks #4702
Sash double clicks #4702
Conversation
Hi @mquandalle, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@mquandalle, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
@mquandalle I would just suggest to make the side bar size to its minimal width. Since we never show horizontal scrollbars, every size is good enough to show the contents within. Minimal width is defined in https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/browser/layout.ts#L20 |
That would be pretty easy but if you look at Sublime and Atom they both have a smarter implementation that measures the width of the explorer items and uses the larger one as the sidebar width. Do the test! For example if you have an opened sidebar at its “optimal width” and you open some folder that contains longer file names, double clicking on the sidebar border will re-calculate a larger width. As described in #4660 I’d like to have the same behavior on VSCode. So the idea was to use a static width (like indeed |
@mquandalle I see, there is currently no API to compute the optimal width of the explorer tree to prevent truncating of words, but maybe @joaomoreno could chime in on that topic. |
Renamed stash to sash in the title. @bpasero @mquandalle It can be done, but it is non-trivial. |
56a86a7
to
9da61e8
Compare
I got a first version of explorer optimal resizing working in 9da61e8. |
@mquandalle cool, I think it would make somewhat more sense that every viewlet can implement a function to provide its optimal width. That way, the double click works with all viewlets. If a viewlet decides to not provide optimal width, it should just fallback to the minimal view width as indicated before. I think you also need to take into account some other aspects: The working files view to the top also has labels that might get truncated. However, I would not expect that the full path of a working file gets revealed, only its label 👍 |
Yes, that’s exactly how I implemented it.
Sure, currently I only take into account the explorer tree width but adding the working view as you say makes total sense. |
} | ||
|
||
.horizontal-cursor-container * { | ||
cursor: ns-resize !important; |
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.
Why is this needed?
I added some comments to the code |
a4fa580
to
76a8ce0
Compare
Also note that the current DOM measurement strategy has two important drawbacks:
For comparison both Atom and Sublime handle (2) correctly and don’t have problem (1) as they don’t allow sidebar opening using the mouse. |
@mquandalle thanks, can you resolve the merge conflicts in this PR? I will have a look soon and provide feedback. |
@mquandalle actually much easier to review your change without merging master back in. just let it be :) |
@mquandalle getting there, works very nice now. Some more feedback:
|
Thank you for the feedback, I should be able to amend the PR soon. Do you have any comment on #4702 (comment)? |
@mquandalle sure:
|
We had to implement a slight change in the sash drag "hack", by removing the full cover transparent overlay (that was preventing clicks events from being fired) and replacing it by a CSS `cursor` rule on the document.body. The ideal solution for a clean dragging events implementation would be to use the `Element.setCapture` API that is unfortunately not available in Chrome.
The calculus was plain wrong as showed in winjs/winjs#1621 This was probably unotified since this utility function wasn't used in the code base.
28cd1ad
to
0fb5a80
Compare
I rebased my branch on master` to solves the (trivial) merge conflict. I also added a commit to address your #4702 (comment) points. Points 1 and 3 are fixed, but I have a doubt about 2. You say that I’m not handling the case when |
@mquandalle changes look good! you are right, getExplorerView() will return only the explorer view, but it can return null in case you did not open a folder (just try to File > Close Folder and doubleclick on the explorer sash). |
0fb5a80
to
6b207f2
Compare
Ok, it's fixed. |
This commit also moves the `getOptimalWidth` method from the `Composite` to the `Viewlet` component. This partially addresses microsoft#4702 (comment)
6b207f2
to
bfe45ae
Compare
Thanks so much, merged to master! |
* Support double click on sashes We had to implement a slight change in the sash drag "hack", by removing the full cover transparent overlay (that was preventing clicks events from being fired) and replacing it by a CSS `cursor` rule on the document.body. The ideal solution for a clean dragging events implementation would be to use the `Element.setCapture` API that is unfortunately not available in Chrome. * Center the split editor frontier by double-clicking on it * Reset the bottom panel size by double-clicking on it * Implement sash reset on diff editors * Fix a bug with DOM measurement The calculus was plain wrong as showed in winjs/winjs#1621 This was probably unotified since this utility function wasn't used in the code base. * Implement sidebar sash optimal resizing Fixes #4660 * Abstract `getLargestChildWidth` into a DOM method This commit also moves the `getOptimalWidth` method from the `Composite` to the `Viewlet` component. This partially addresses #4702 (comment) * Calculate the sidebar optimal width correctly in case no folder is open
Thanks @mquandalle, I've been wanting this for a while! 🎆 |
Start implementing #4660.
The provided code defines a new event that is fired when a “stash” is double-clicked, and two usages of it—the first one on the spitted editor frontiers, and the second one on the bottom panel border. It is easier to review this PR commit per commit.
The capture below demonstrates the feature on the spitted editor:
I may want in implement the “sidebar optimal sizing” that originally motivated #4660, but I would like to have some guidance on the code structure:
IViewletView
the right place to implement an optionalgetOptimalWidth
method? [edit: I’ve chosenIViewlet
instead]DOM.getTotalWidth
andDOM.getRelativeLeft
]vs/workbench/layout.ts
? [edit: the viewlet service]Thank you in advance for considering this contribution :-)