-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add Pinned Tabs #10817
Add Pinned Tabs #10817
Conversation
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 noticed some minor issues in this feature:
- Pinning a side bar tab prevents it from closing. Moving this pinned tab to the main area leaves it in an invalid state. The usual close icon is displayed and works as expected. However, the context menu entry for
Pin
is disabled and the one forUnpin
is enabled. - Pinning a focused tab removes the focus from the tab. VSCode refocuses the target tab of the context menu after it closes. This one might not have to do with your PR and is probably more of a general issue of how context menus and tab focus work.
h.div({ | ||
className: 'p-TabBar-tabCloseIcon', | ||
onclick: this.handleCloseClickEvent | ||
}) |
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.
Minor: This item is missing its hovering effect. You can simply add the action-item
class to enable it.
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.
Thanks. I think the original PR predated your work in that area.
export const PIN_TAB = Command.toDefaultLocalizedCommand({ | ||
id: 'workbench.action.pinEditor', | ||
category: VIEW_CATEGORY, | ||
label: 'Pin Tab' | ||
}); | ||
export const UNPIN_TAB = Command.toDefaultLocalizedCommand({ | ||
id: 'workbench.action.unpinEditor', | ||
category: VIEW_CATEGORY, | ||
label: 'Unpin Tab' | ||
}); |
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.
The eslint rule doesn't really work for toDefaultLocalizedCommand
(I should fix this perhaps)
Pin
and Unpin
are the labels used by VSCode and can both be found in the nls.metadata.json
file.
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 did wonder about whether the linting would catch it for the other NLS utilities. I'll update the text.
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 actually just noticed that VSCode is using Pin editor
/Unpin editor
. Since we do not only allow pinning on editors, we should maybe introduce new translations here? Or is Pin editor
accurate enough for the command label?
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 editors are going to be the most common targets, in any case, so I'll use '(un)pin editor' for now.
@msujew, thanks for the review. Do you remember which views had problems in this scenario? It seems some widgets are OK (e.g. editors) and others unpin themselves (e.g. extensions). If you remember which ones you had trouble with, I'll be sure to test them and figure out what's going wrong. |
4e6dc30
to
8e1fdaa
Compare
@msujew, I think the problem was probably code in |
f39b1f7
to
c17ac0e
Compare
}, | ||
{ | ||
command: CommonCommands.UNPIN_TAB.id, | ||
keybinding: 'ctrlcmd+k shift+enter', |
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 noticed that pinning does work using the specified keyboard shortcut. However, unpinning does not work for some reason.
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.
It turns out this was also a consequence of the 'editor' vs. 'widget' question. An earlier version of the PR had either had two context keys or only activeWidgetIsPinned
and it was switched to editor
to agree with VSCode, but the keybindings still referred to widget
.
Add icons for pinned tabs Add keybindings for pinning and unpinning tabs Add a TODO notice for icons Add activeEditorIsPinned context key Add activeWidgetIsPinned context key while keeping vscode compatibility Change pin/unpin commands to use activeWidgetIsPinned Use VS Code command IDs for pin/unpin Create TheiaTitle type Refactor checks for pinning Make preview editor non-preview when pinned Unpin tab by clicking on icon Fix reordering when unpinning Do not rearrange tabs when pinned/unpinned Make TheiaTitle a generic type Co-authored-by: Colin Grant <[email protected]> Co-authored-by: Dmitry Sharshakov <[email protected]>
2d24776
to
9f45e11
Compare
9f45e11
to
eef3aeb
Compare
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.
Alright, I noticed a minor issue with the keyboard shortcut: When an editor is unfocused (for example by clicking on the tab-bar), using the shortcut to pin works, but using it to unpin does not. It works in every other case that I've tested. Since this is quite minor, I will approve this PR nonetheless, as everything else is working.
- Pinning/Unpinning editors using the Command/Context Menu works correctly
- Also works mostly correctly with the shortcut
- It also works as expected for other widgets, like
Search
andDebug
, even when the widget is on the sidebar - The context menu entries related to closing files are correctly disabled depending on which widgets are pinned.
I appreciate the thorough testing! I will check on this scenario. |
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 confirmed the following 👍
- pinning/unpinning works
- pinning/unpinning tabs in the main-area properly decorate the tab with the pin icon
- pinning a editor-preview works, the editor becomes persistent
- pinning dirty editors works, the tab is decorated with the dirty pin icon
- pinning tabs in the sidepanels work well
- pinned tabs are uncloseable unless unpinned first
- pinned tabs are persistent on reloads
- pinning with the keyboard shortcut works well
- unpinning with the keyboard shortcut does not seem to work for some widgets (ex: reproducible with search-in-workspace) (likely what Mark noticed too)
@msujew, @vince-fugnitto, thanks again for the thorough reviews. I believe I tracked down the problem with unpinning unfocused widgets: the context key setting and the command enablement were looking at different conditions. I have adjusted the code so that the context key is always looking at the same widget as the command will act on. |
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 confirmed that the outstanding issue regarding the keyboard shortcut has been fixed, the last issue in #10817 (review) now works 👍
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.
Thanks Colin, that last change seems to have done it 👍
What it does
Commands for pinning and unpinning tabs. Fixes #9326. Closes #9614.
This is based on #9614 with a bug fix and a switch to codicons for pinned tab icons.
How to test
Review checklist
Reminder for reviewers