Add border for dirty tabs#59759
Conversation
|
@usernamehw I briefly looked into this last milestone and I think to do this right, the following is needed:
Thanks |
1. Make it thinner 2. Add a setting to disable it 3. Use 4 colors (activeFocused, activeUnfocused, inactiveFocused, inactiveUnfocused) 4. Move part of logic
|
cc @bpasero |
|
|
||
| export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = { | ||
| showTabs: true, | ||
| dirtyTabBorder: false, |
src/vs/workbench/common/editor.ts
Outdated
|
|
||
| export interface IWorkbenchEditorPartConfiguration { | ||
| showTabs?: boolean; | ||
| dirtyTabBorder?: boolean; |
src/vs/workbench/common/theme.ts
Outdated
| hc: null | ||
| }, nls.localize('tabActiveBorderTop', "Border to the top of an active tab. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups.")); | ||
|
|
||
| export const TAB_DIRTY_ACTIVE_FOCUSED_BORDER = registerColor('tab.dirtyActiveFocusedBorder', { |
There was a problem hiding this comment.
To make it easier for theme authors, 3 of the 4 colors should be derived from the one main color. E.g. you can reference the main color and then apply opacity to the color to alter it. That way, a theme can only define the main color and is all set.
src/vs/workbench/common/theme.ts
Outdated
| hc: null | ||
| }, nls.localize('tabDirtyActiveFocusedBorder', "Border on the top of dirty active tab in active editor group.")); | ||
|
|
||
| export const TAB_DIRTY_ACTIVE_UNFOCUSED_BORDER = registerColor('tab.dirtyActiveUnfocusedBorder', { |
There was a problem hiding this comment.
I suggest tab.modified instead of tab.dirty for the colors
| 'description': nls.localize('showEditorTabs', "Controls whether opened editors should show in tabs or not."), | ||
| 'default': true | ||
| }, | ||
| 'workbench.editor.dirtyTabBorder': { |
| }, | ||
| 'workbench.editor.dirtyTabBorder': { | ||
| 'type': 'boolean', | ||
| 'description': nls.localize('showEditorDirtyTabBorder', "Controls whether top border is drawn on dirty file tabs or not."), |
There was a problem hiding this comment.
"Controls wether modified tabs are highlighted"
There was a problem hiding this comment.
I think some people would search for border keyword to look it up in settings. It already has highlight in setting itself; combined with border should provide more searchable result.
| if (editor.isDirty()) { | ||
| addClass(tabContainer, 'dirty'); | ||
|
|
||
| if (this.accessor.partOptions.dirtyTabBorder && !this.getColor(TAB_ACTIVE_BORDER_TOP)) { |
There was a problem hiding this comment.
Sorry for not being clear here: instead of assigning a CSS class, why not set the border color directly on the element? I wanted to avoid having a new CSS rule produced for this feature.
src/vs/workbench/common/theme.ts
Outdated
| }, nls.localize('tabActiveBorderTop', "Border to the top of an active tab. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups.")); | ||
|
|
||
| export const TAB_DIRTY_ACTIVE_FOCUSED_BORDER = registerColor('tab.dirtyActiveFocusedBorder', { | ||
| dark: null, |
There was a problem hiding this comment.
I suggest to assign a default color here for dark and light theme so that enabling the setting has a visible impact.
|
@bpasero , can't make it work with In any way, awaiting more feedback. |
|
@usernamehw actually that is a good point, why are you using |
|
Using 1px height div? |
|
It's almost working now, I need only to fix 2px shifted |
|
@usernamehw yeah maybe you can use the same element we already use for the border and make it 2px instead. |
|
@usernamehw I was not suggesting to set a border on each tab (this will have the ugly side effect of pushing down the label within) but rather reuse the DIV that is the container of the top border already (https://github.com/Microsoft/vscode/blob/c09511ccc1f67b08ebda9141d49a030cc381865e/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts#L881). Can we not utilize that one for this purpose since it is already there? Should make things much simpler. |
|
@bpasero, This should be close to the final version. I commented out 2 lines that seemed redundant... Is there a reason they were there?: tabContainer.style.removeProperty('--tab-border-bottom-color');
// ...
tabContainer.style.removeProperty('--tab-border-top-color'); |
|
Should |
I think its fine to leave them, we remove a CSS variable that we added before. Its more a cleanup operation without visual impact.
Yes, why not. This list is probably out of date by now anyways, I typically forget to update it. |
|
Thanks, this is good to merge. I did some slight changes:
|
|
Actually I will push another change to ensure that the dirty border always wins even if a normal border is configured. It seems to me the modified border is much more specific compared to a normal border from the theme and should always win. |

Fixes #26284
Adds a themable top border for tabs.
Disabled in
hcthemes.Disabled if
tab.activeBorderTopis set.2pxborder does't look very good using light themes(especially fullscreen).