mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
editor: Hide horizontal scrollbar if not visible (cherry-pick #23337) (#23338)
Some checks failed
CI / Check Postgres and Protobuf migrations, mergability (push) Has been cancelled
CI / Check formatting and spelling (push) Has been cancelled
CI / (macOS) Run Clippy and tests (push) Has been cancelled
CI / (Linux) Run Clippy and tests (push) Has been cancelled
CI / (Linux) Build Remote Server (push) Has been cancelled
CI / (Windows) Run Clippy and tests (push) Has been cancelled
CI / Create a macOS bundle (push) Has been cancelled
CI / Linux x86_x64 release bundle (push) Has been cancelled
CI / Linux arm64 release bundle (push) Has been cancelled
CI / Auto release preview (push) Has been cancelled
Some checks failed
CI / Check Postgres and Protobuf migrations, mergability (push) Has been cancelled
CI / Check formatting and spelling (push) Has been cancelled
CI / (macOS) Run Clippy and tests (push) Has been cancelled
CI / (Linux) Run Clippy and tests (push) Has been cancelled
CI / (Linux) Build Remote Server (push) Has been cancelled
CI / (Windows) Run Clippy and tests (push) Has been cancelled
CI / Create a macOS bundle (push) Has been cancelled
CI / Linux x86_x64 release bundle (push) Has been cancelled
CI / Linux arm64 release bundle (push) Has been cancelled
CI / Auto release preview (push) Has been cancelled
Cherry-picked editor: Hide horizontal scrollbar if not visible (#23337) This PR fixes two visual issues, that were caused by the fact that we were always painting the horizontal scrollbar even if there is no horizontal scrolling possible Obscuring deleted lines when using the inline assistant: https://github.com/user-attachments/assets/f8460c3f-403e-40a6-8622-65268ba2d875 Cutting off text even when horizontal scrolling is not possible: https://github.com/user-attachments/assets/23c909f7-1c23-4693-8edc-40a2f089d4a8 This issue was only present in some themes (e.g. Nord, Catpuccin) Closes #22716 Release Notes: - Fixed an issue where horizontal scrollbars of editors would always be painted (even if there is no horizontal scrolling to be done) Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
This commit is contained in:
parent
349fb5254d
commit
41a267d49b
3 changed files with 8 additions and 2 deletions
|
@ -1204,6 +1204,7 @@ impl InlineAssistant {
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_gutter(false, cx);
|
editor.set_show_gutter(false, cx);
|
||||||
editor.scroll_manager.set_forbid_vertical_scroll(true);
|
editor.scroll_manager.set_forbid_vertical_scroll(true);
|
||||||
|
editor.set_show_scrollbars(false, cx);
|
||||||
editor.set_read_only(true);
|
editor.set_read_only(true);
|
||||||
editor.set_show_inline_completions(Some(false), cx);
|
editor.set_show_inline_completions(Some(false), cx);
|
||||||
editor.highlight_rows::<DeletedLines>(
|
editor.highlight_rows::<DeletedLines>(
|
||||||
|
|
|
@ -1276,6 +1276,7 @@ impl InlineAssistant {
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_gutter(false, cx);
|
editor.set_show_gutter(false, cx);
|
||||||
editor.scroll_manager.set_forbid_vertical_scroll(true);
|
editor.scroll_manager.set_forbid_vertical_scroll(true);
|
||||||
|
editor.set_show_scrollbars(false, cx);
|
||||||
editor.set_read_only(true);
|
editor.set_read_only(true);
|
||||||
editor.set_show_inline_completions(Some(false), cx);
|
editor.set_show_inline_completions(Some(false), cx);
|
||||||
editor.highlight_rows::<DeletedLines>(
|
editor.highlight_rows::<DeletedLines>(
|
||||||
|
|
|
@ -1333,11 +1333,15 @@ impl EditorElement {
|
||||||
total_text_units
|
total_text_units
|
||||||
.horizontal
|
.horizontal
|
||||||
.zip(track_bounds.horizontal)
|
.zip(track_bounds.horizontal)
|
||||||
.map(|(total_text_units_x, track_bounds_x)| {
|
.and_then(|(total_text_units_x, track_bounds_x)| {
|
||||||
|
if text_units_per_page.horizontal >= total_text_units_x {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let thumb_percent =
|
let thumb_percent =
|
||||||
(text_units_per_page.horizontal / total_text_units_x).min(1.);
|
(text_units_per_page.horizontal / total_text_units_x).min(1.);
|
||||||
|
|
||||||
track_bounds_x.size.width * thumb_percent
|
Some(track_bounds_x.size.width * thumb_percent)
|
||||||
}),
|
}),
|
||||||
total_text_units.vertical.zip(track_bounds.vertical).map(
|
total_text_units.vertical.zip(track_bounds.vertical).map(
|
||||||
|(total_text_units_y, track_bounds_y)| {
|
|(total_text_units_y, track_bounds_y)| {
|
||||||
|
|
Loading…
Reference in a new issue