Repository navigation
fix: #5353 use available sidebar height for opened files - #5473
Phdigital33 wants to merge 5 commits into
Conversation
Jocs
left a comment
There was a problem hiding this comment.
Thanks for picking this up — the diagnosis is right and the folder-open half works. I built this branch and measured the real app (macOS, 1200×800, sidebar panel 800px tall), and there is a regression in the no-folder branch, which is exactly the case #5353 reports.
What I confirmed works
- With a folder open and 33 tabs:
.opened-filessettles at 400px (= 50%) and the project tree keeps 365px. Ondevelopthe list was clamped to 112px with 784px hidden. Clear improvement. - The new spec is a genuine regression test for that case: reverting only
tree.vuetodevelopmakes it fail withExpected: 0 / Received: 112. Good. pnpm run lint→ 0 errors here too.
Blocking: flex: 1 pins "Open Folder" to the bottom edge
.files-only .opened-files { flex: 1 } sets flex-grow: 1; flex-basis: 0, so the opened-files box swallows the whole panel no matter how few tabs are open, and .open-project (now flex: none) is pushed to the very bottom. Measured with a genuinely null projectTree (mt::load-state with project: {}), 800px panel:
| tabs | .opened-files height |
list content | "Open Folder" top | same on develop |
|---|---|---|---|---|
| 1 | 681px | 28px | 748 (panel ends at 800) | 391 |
| 7 | 681px | 196px | 748 | 433 |
| 33 | 681px | 924px (scrolls) | 748 | 433 |
So with 7 tabs the user gets their files (the bug is fixed) plus ~455px of blank list, and the green "Open Folder" button glued to the bottom edge, level with the settings gear in the icon strip. Collapsing the "Opened files" section drops files-only and the button jumps back up 371px — a large, unexplained jump for a section toggle.
The fix is one token — grow is not what you want here, only shrink:
.files-only .opened-files {
flex: 0 1 auto; /* was: flex: 1 */
max-height: none;
}I verified it on this branch: the button now follows the list (top 97 / 125 / 293 for 1 / 2 / 8 tabs), and the 33-tab case is byte-identical to what the PR does today (681px list, button at 748, list scrolls). .open-project already has flex-shrink: 0 from flex: none, so the list is the only thing that shrinks. This is also what VS Code does — the "No Folder Opened" body follows the Open Editors section, it is not anchored to the window bottom.
The .files-only branch has no test coverage
launchElectron passes the desktop package directory as the Electron entry argument, so main opens it as a project: projectTree is never null under launchWithMarkdown. I logged .tree-view.className at every step of the new test — it is "tree-view" throughout, never "tree-view files-only". Three of the five new CSS rules, covering the scenario the issue actually describes, are untested. sendIpcToRenderer(app, 'mt::load-state', { editor: { tabs: [], currentFileId: null }, project: {}, layout: { rightColumn: 'files', showSideBar: true, showTabBar: true } }) reaches that state and renders .open-project for real.
Two smaller things in the same spec:
setSize(1000, 400)is only undone on the happy path. The tests in thisdescribeshare one app frombeforeAll, so a failure at eithertoBeInViewportleaves the window 400px tall for the next test. Restore it intest.afterEachor afinally.await page.screenshot({ path: test.info().outputPath('sidebar.png') })looks like leftover debugging — it asserts nothing.
Interaction design vs. VS Code's Open Editors
The issue asks for VS Code's behaviour, and max-height: 50% is a different model. VS Code sizes the Open Editors pane to its content up to explorer.openEditors.visible (default 9 rows), scrolls past that, and lets you drag the sash between the two sections, persisting the size. A fixed half-panel diverges in both directions, and one case is easy to hit today:
Collapse the folder section (fold its arrow) with 33 tabs open.
.project-treekeepsflex: 1and holds 365 of 800px completely blank, while.opened-filesstays capped at 400px with 526px of the file list still hidden.
Measured on this branch. In VS Code a collapsed pane shrinks to its header and the remaining panes reflow into the freed space.
Two ways forward, either is fine by me:
- Cheap, still CSS-only: cap by rows instead of by panel share —
max-height: min(50%, <N> * 28px)— so the cap reads as "at most N files, likeexplorer.openEditors.visible" rather than "half the panel", and additionally release the height of a collapsed section (adirectories-collapsedclass that sets.project-tree { flex: none }, mirroring thefiles-onlyclass you already added). - Closer to VS Code: make the divider between the two sections draggable and persist it in
localStoragenext toside-bar-show-directories/ the sidebar width. That is the thing users actually reach for, and it makes the whole percentage question go away. Happy to take it as a follow-up PR rather than growing this one.
Nits
.opened-files > .title { flex-shrink: 0 }duplicates the.opened-files > .title, .project-tree > .titlerule ~50 lines above — please merge it there instead of adding a second block.- The
<div v-if="openedFilesInSidebar" class="opened-files">reflow into four lines is pure diff noise; the single-line form already passed lint. - With
.files-only .open-project { flex: none }, thejustify-content: space-aroundandpadding-bottom: 100pxon.open-projectbecome dead in that branch. Worth a comment saying why the padding exists only in the folder-less, section-collapsed case, or dropping it.
`flex: 1` expands to `flex-grow: 1; flex-basis: 0`, so with no project open the opened-files box claimed the whole panel no matter how few files were open and pushed the "Open folder" button onto the bottom edge of the sidebar: with one file the list held 28px of rows and 653px of blank space. Collapsing the section then moved the button back up by 371px. Drop the cap without the grow. The list keeps the initial `flex: 0 1 auto`, so it tracks its content and only shrinks once the panel runs out of room — which is what the long-list case relied on anyway; 33 open files still fill 651px and scroll exactly as before. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`.project-tree` grows into the panel whether or not it is showing anything, so collapsing it to its header freed nothing: with 33 files open it kept 365 of 800px blank while the opened-files list stayed capped at half the panel with 526px of rows still scrolled out of view. Stop the directory section from growing while it is collapsed, and lift the half-panel cap whenever it claims no height — there is then nothing to share with. Collapsing the section now hands the list 735px and leaves 191px hidden instead of 526px. This is how VS Code's explorer panes behave, and it doubles as the manual control the sidebar otherwise lacks: a user who wants to see more open files than half the panel can collapse the folder tree to get them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… block The header height was declared in one rule and its shrink behaviour in another 50 lines below. Both headers are flex items of a container that is now free to shrink, so neither should give up its declared 30px. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The spec lived in the marktext#2421 file, whose header scopes it to that issue, and it only reached one of the three layouts. The e2e harness passes the desktop package directory as the Electron entry, so main opens it as a project and `projectTree` is never null — the folder-less branch, which is the layout marktext#5353 actually reports, had no coverage at all. Replaying an empty buffered state over `mt::load-state` gets there. Move it to its own file and cover the collapsed-directories and folder-less layouts too. Reverting tree.vue to the first draft of this branch fails the two new specs (the list stretches to 651px instead of its 200px of rows) and keeps the first one passing. Also restore the window size from `afterEach` rather than the happy path — the specs share one app, so a mid-spec failure handed the next one a 400px window — and drop the screenshot that asserted nothing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Rather than send you round-trips: the folder-open half of this was already right, so I pushed four commits onto the branch instead. All the measurements are in the commit messages.
One correction to my review: I called the Why the folder-less branch had no coverage, for future specs in this area: Deliberately not in this PR:
Locally: Thanks for the original diagnosis and for the regression test — the 112px cap was exactly the right thing to go after. |
|
Closing this, and the decision is mine rather than anything about the patch — I took the review further than I should have before settling the question I should have settled first: whether the 112px cap is a problem worth changing at all. I've concluded it isn't. MarkText's tab bar already lists every open file, so nothing is hidden when the sidebar shows four rows — the same information is one glance away, and the sidebar section is a second copy of it. VS Code, which I leaned on throughout this review, reached the same conclusion from the other direction: it ships Open Editors collapsed by default because the tab bar is how people actually switch files. I was citing it as an argument for giving the section more room, which had it backwards. That makes #5353 a brief misreading rather than a functional gap, and not worth a layout rule whose failure modes I had to measure this carefully to trust. Your diagnosis was right and I want to be clear about that: the hard-coded 112px was exactly the thing to point at, and the regression test you wrote genuinely fails on Closing #5353 alongside this. If more people run into the same confusion, reopening both is cheap and the analysis in this thread is all still good. |
Closes #5353
Summary
The Opened files list stops after four rows because its maximum height is fixed at 112px. With eight files open, half the list scrolls out of view even in a tall sidebar.
Let the list grow with the window, using up to half the sidebar when a project tree is present. With no project, use the remaining height and keep Open Folder visible. Scrolling still handles short windows and larger lists.
Before / after
Type of change
Test plan
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.