-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Add border for dirty tabs #59759
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 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 |
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.
@@ -30,6 +30,7 @@ export interface IEditorPartOptions extends IWorkbenchEditorPartConfiguration { | |||
|
|||
export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = { | |||
showTabs: true, | |||
dirtyTabBorder: false, |
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.
Suggest: highlightModifiedTabs
src/vs/workbench/common/editor.ts
Outdated
@@ -938,6 +938,7 @@ export interface IWorkbenchEditorConfiguration { | |||
|
|||
export interface IWorkbenchEditorPartConfiguration { | |||
showTabs?: boolean; | |||
dirtyTabBorder?: boolean; |
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.
Suggest: highlightModifiedTabs
src/vs/workbench/common/theme.ts
Outdated
@@ -66,6 +66,30 @@ export const TAB_ACTIVE_BORDER_TOP = registerColor('tab.activeBorderTop', { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest tab.modified
instead of tab.dirty
for the colors
@@ -480,6 +480,11 @@ configurationRegistry.registerConfiguration({ | |||
'description': nls.localize('showEditorTabs', "Controls whether opened editors should show in tabs or not."), | |||
'default': true | |||
}, | |||
'workbench.editor.dirtyTabBorder': { |
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.
Suggest: highlightModifiedTabs
@@ -480,6 +480,11 @@ configurationRegistry.registerConfiguration({ | |||
'description': nls.localize('showEditorTabs', "Controls whether opened editors should show in tabs or not."), | |||
'default': true | |||
}, | |||
'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Controls wether modified tabs are highlighted"
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 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.
@@ -908,8 +909,15 @@ export class TabsTitleControl extends TitleControl { | |||
private redrawEditorDirty(editor: IEditorInput, tabContainer: HTMLElement): void { | |||
if (editor.isDirty()) { | |||
addClass(tabContainer, 'dirty'); | |||
|
|||
if (this.accessor.partOptions.dirtyTabBorder && !this.getColor(TAB_ACTIVE_BORDER_TOP)) { |
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.
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.
@@ -66,6 +66,30 @@ export const TAB_ACTIVE_BORDER_TOP = registerColor('tab.activeBorderTop', { | |||
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', { | |||
dark: null, |
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 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
hc
themes.Disabled if
tab.activeBorderTop
is set.2px
border does't look very good using light themes(especially fullscreen).