Skip to content
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

fix: fix editor progress position when enabled pinnedTabsOnSeparateRow #195314

Merged
merged 17 commits into from
Oct 23, 2023

Conversation

harbin1053020115
Copy link
Contributor

To #195313

@gjsjohnmurray
Copy link
Contributor

/assign @benibenj

@bpasero bpasero removed their assignment Oct 11, 2023
@bpasero bpasero added this to the October 2023 milestone Oct 11, 2023
Copy link
Contributor

@benibenj benibenj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting the bug and creating a PR! I left some comments to your changes

@@ -404,12 +404,13 @@ export abstract class EditorTabsControl extends Themable implements IEditorTabsC

protected updateTabHeight(): void {
this.parent.style.setProperty('--editor-group-tab-height', `${this.tabHeight}px`);
this.parent.parentElement?.style.setProperty('--editor-group-tab-total-height', `${this.tabHeight * (this.groupsView.partOptions.pinnedTabsOnSeparateRow ? 2 : 1)}px`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably won't work. Even though the pinnedTabsOnSeparateRow setting might be activated, this doesn't mean that two tab rows are actually visible. If all tabs are pinned or if there is no pinned tab then there will only be one tab row and so the height of the progress bar has to be change in these cases.

We handle the number of tab rows here.

src/vs/workbench/browser/media/part.css Outdated Show resolved Hide resolved
@harbin1053020115
Copy link
Contributor Author

@benibenj You are right. The first commit won't work. Even pinnedTabsonSeparateRow setting is activated, there will be just one tab row if where is no pinned tabs opened.
And, I found it's not a good way to update tab height dynamic using css variable, we need to conside many scenarios:

  1. When open/close/pinned editors, we need to update height according to opened tabs height
  2. When moving opened editors in editor title, we need to update height according to opened tabs height
  3. When pinnedTabsonSeparateRow/editorTabHeight setting is changed, we need to update height
    So, I have changed the way to realize, I moved the editor progress bar into titleContainer, and make the progress bar at the bottom of titleContainer

@harbin1053020115
Copy link
Contributor Author

harbin1053020115 commented Oct 16, 2023

Below is the result of progress bar:

  1. normal:
    image
  2. window.density.editorTabHeight setting changed to compact:
    image
  3. breadcrumbs.enabled enabled:
    image
  4. pinnedTabsonSeparateRow enabled:
    image

@benibenj
Copy link
Contributor

benibenj commented Oct 18, 2023

I think we should still set the progress bar from the top as we did before. Your approach causes it to be placed underneath the breadcrumbs which did not used to be the case, and so we don't want to change that.

This is my recommendation:

We already know the height of the editor title control. It can be accessed in editorTitleControl.ts. Like in your first approach, you can introduce a CSS variable, and overwrite the absolute top position of the progress bar in editorgroupview.css (This is where the progress bar lives). The variable could be called --editor-group-tabs-height as we already have --editor-group-tab-height. I wouldn't call it title height as we do not want to include the breadcrumbs height.

The last thing to do now is update the value when there are changes to the layout, these could be:

  • changing window.density.editorTabHeight setting
  • changing workbench.editor.pinnedTabsOnSeparateRow setting
  • changing workbench.editor.wrapTabs setting
  • On layout() (in case of resizing the editor for example) when using wrapped tabs
  • When opening, closing and moving an editor
  • When sticking and unsticking (known as pinning and unpinning) an editor

The last two are specific to having some settings turned on, however, we can start off by updating the height every time as it is not an expensive operation and future proof. But we might change this in the future.

@harbin1053020115
Copy link
Contributor Author

I think we should still set the progress bar from the top as we did before. Your approach causes it to be placed underneath the breadcrumbs which did not used to be the case, and so we don't want to change that.

This is my recommendation:

We already know the height of the editor title control. It can be accessed in editorTitleControl.ts. Like in your first approach, you can introduce a CSS variable, and overwrite the absolute top position of the progress bar in editorgroupview.css (This is where the progress bar lives). The variable could be called --editor-group-tabs-height as we already have --editor-group-tab-height. I wouldn't call it title height as we do not want to include the breadcrumbs height.

The last thing to do now is update the value when there are changes to the layout, these could be:

  • changing window.density.editorTabHeight setting
  • changing workbench.editor.pinnedTabsOnSeparateRow setting
  • changing workbench.editor.wrapTabs setting
  • On layout() (in case of resizing the editor for example) when using wrapped tabs
  • When opening, closing and moving an editor
  • When sticking and unsticking (known as pinning and unpinning) an editor

The last two are specific to having some settings turned on, however, we can start off by updating the height every time as it is not an expensive operation and future proof. But we might change this in the future.

Got it. Let me submit a change.

@benibenj benibenj requested a review from bpasero October 23, 2023 09:04
@benibenj
Copy link
Contributor

@harbin1053020115 The change looks great! Thanks very much.
I removed the method you added as we can update the variable in the editorGroupView when we call the layout method.

@harbin1053020115
Copy link
Contributor Author

@harbin1053020115 The change looks great! Thanks very much. I removed the method you added as we can update the variable in the editorGroupView when we call the layout method.

Great~Moving to layout to reset css variable is a better way.

@bpasero bpasero merged commit bf9068c into microsoft:main Oct 23, 2023
6 checks passed
Alex0007 pushed a commit to Alex0007/vscode that referenced this pull request Oct 26, 2023
microsoft#195314)

* fix: fix editor progress position when enabled pinnedTabsOnSeparateRow

* fix: fix editor progress position

* fix: fix editor progress position

* fix: add commit to editor title progress style

* Revert "fix: add commit to editor title progress style"

This reverts commit 302ec88.

* Revert "fix: fix editor progress position"

This reverts commit ec445b6.

* Revert "fix: fix editor progress position"

This reverts commit cea64be.

* Revert "fix: fix editor progress position when enabled pinnedTabsOnSeparateRow"

This reverts commit 8f2c0e7.

* feat: add --editor-group-tabs-height css variable to set progress bar position

* update height in lyout

* Remove setting redraws as already done elsewhere

* Remove 2px for progress bit height

---------

Co-authored-by: ermin.zem <ermin.zem@alibaba-inc.com>
Co-authored-by: BeniBenj <besimmonds@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants