This PR introduces the `project_panel.scrollbar.horizontal_scroll`
setting to allow users to toggle the horizontal scroll bar in the
project panel. This was Zed's design before PR #18513, and the default
behavior of VSCode (`workbench.list.horizontalScrolling`).
https://github.com/user-attachments/assets/f633f4e4-a585-4494-8f48-df77c6aca418
## Rationale
Zed's design used to be the same as the default behavior of VSCode.
I.e., no horizontal scrolling, and the view is always snapped to the
left, with long file names clipped of. If you want to see the content
that is out-of-frame, you'll need to drag the handle and expand the
project panel. This could be problematic, especially for large repos
with multiple levels of nested directories, as pointed out by issues
#5550 and #7001.
<img width="1398" height="992" alt="image"
src="https://github.com/user-attachments/assets/d86563f2-0f06-4e9e-818c-155ac45f0f56"
/>\
*VSCode's default setup, for reference.*
Then came PR #18513, which added horizontal scroll and addressed this
pain point, but users didn't have a choice. They're stuck with
horizontal scrolling always turned on. I, for instance, personally
prefer the old, VSCode-default behavior, for most projects I open are
small and don't need horizontal scrolling in the project panel. With
horizontal scrolling always turned on, I find it annoying to have my
project panel view accidentally scrolled to the middle, and I'll have to
grab my mouse and scroll it back. It's also visually redundant.
Thus, why not add an option like VSCode's
`workbench.list.horizontalScrolling` and let users choose? I'd love to
be able to, say, set a per-project override for the projects that need
horizontal scrolling, while having it disabled by default.
## Extra Notes
- I was originally thinking about using `ScrollbarAxes` from
`src/editor_settings.rs` and make the option
`project_panel.scrollbar.axes.horizontal` similar to the global editor
scrollbar settings, but this option is specific to the project panel and
it doesn't quite make sense to allow disabling vertical scrolling on the
project panel, so I added a standalone option for it instead, similar to
VSCode's `workbench.list.horizontalScrolling`.
- I went the conservative route and set horizontal scrolling to enabled
(current behavior) by default. Imo it might make more sense to disable
it by default instead, similar to VSCode, but I'll leave this for the
Zed team to decide.
- I named it `horizontal_scroll` instead of `horizontal_scrolling` to be
consistent with the adjacent setting `sticky_scroll`.
- As for tests, I don't see tests for the scrollbar, so I didn't add
any.
I'd be glad to update the PR if anything is not inline with the
project's requirements or conventions.
---
Release Notes:
- Added `project_panel.scrollbar.horizontal_scroll` setting to allow
toggling horizontal scrolling in the project panel
Signed-off-by: k4yt3x <i@k4yt3x.com>
@@ -768,6 +768,9 @@
// 5. Never show the scrollbar:
// "never"
"show": null,
+ // Whether to allow horizontal scrolling in the project panel.
+ // When false, the view is locked to the leftmost position and long file names are clipped.
+ "horizontal_scroll": true,
},
// Which files containing diagnostic errors/warnings to mark in the project panel.
// This setting can take the following three values:
@@ -4695,7 +4695,8 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
"bold_folder_labels": false,
"drag_and_drop": true,
"scrollbar": {
- "show": null
+ "show": null,
+ "horizontal_scroll": true
},
"sticky_scroll": true,
"show_diagnostics": "all",
@@ -4941,9 +4942,9 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
}
```
-### Scrollbar: Show
+### Scrollbar
-- Description: Whether to show a scrollbar in the project panel. Possible values: null, "auto", "system", "always", "never". Inherits editor settings when absent, see its description for more details.
+- Description: Scrollbar-related settings for the project panel.
- Setting: `scrollbar`
- Default:
@@ -4951,7 +4952,8 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
{
"project_panel": {
"scrollbar": {
- "show": null
+ "show": null,
+ "horizontal_scroll": true
}
}
}
@@ -4959,29 +4961,8 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
**Options**
-1. Show scrollbar in the project panel--```json [settings]-{- "project_panel": {- "scrollbar": {- "show": "always"- }- }-}-```--2. Hide scrollbar in the project panel--```json [settings]-{- "project_panel": {- "scrollbar": {- "show": "never"- }- }-}-```
+- `show`: Whether to show a scrollbar in the project panel. Possible values: null, "auto", "system", "always", "never". Inherits editor settings when absent, see its description for more details.
+- `horizontal_scroll`: Whether to allow horizontal scrolling in the project panel. When `false`, the view is locked to the leftmost position and long file names are clipped.
### Sort Mode