From cb0c613da29805a3a08d26f0e571c312e8db8edc Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Wed, 17 May 2023 12:39:08 -0400 Subject: [PATCH 1/7] v0.88.x dev --- Cargo.lock | 2 +- crates/zed/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41c3eab821..f5b23fe5f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8544,7 +8544,7 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zed" -version = "0.87.0" +version = "0.88.0" dependencies = [ "activity_indicator", "anyhow", diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index b74057c907..ea9ee23971 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Nathan Sobo "] description = "The fast, collaborative code editor." edition = "2021" name = "zed" -version = "0.87.0" +version = "0.88.0" publish = false [lib] From 9e5983305b4ec495886351e5d798084710503174 Mon Sep 17 00:00:00 2001 From: Julia Date: Wed, 17 May 2023 13:38:54 -0400 Subject: [PATCH 2/7] Update font-kit to resolve panics when loading malformed fonts --- Cargo.lock | 64 ++++++++++++++++++++---------------------- crates/gpui/Cargo.toml | 2 +- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 41c3eab821..5664adfa46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1321,6 +1321,12 @@ dependencies = [ "crossbeam-utils 0.8.14", ] +[[package]] +name = "const-cstr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3d0b5ff30645a68f35ece8cea4556ca14ef8a1651455f789a099a0513532a6" + [[package]] name = "context_menu" version = "0.1.0" @@ -1930,6 +1936,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "dlib" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1b7517328c04c2aa68422fc60a41b92208182142ed04a25879c26c8f878794" +dependencies = [ + "libloading", +] + [[package]] name = "dotenvy" version = "0.15.6" @@ -2107,16 +2122,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" -[[package]] -name = "expat-sys" -version = "2.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa" -dependencies = [ - "cmake", - "pkg-config", -] - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -2252,8 +2257,8 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "font-kit" -version = "0.10.0" -source = "git+https://github.com/zed-industries/font-kit?rev=8eaf7a918eafa28b0a37dc759e2e0e7683fa24f1#8eaf7a918eafa28b0a37dc759e2e0e7683fa24f1" +version = "0.11.0" +source = "git+https://github.com/zed-industries/font-kit?rev=b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18#b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18" dependencies = [ "bitflags", "byteorder", @@ -2269,9 +2274,9 @@ dependencies = [ "log", "pathfinder_geometry", "pathfinder_simd", - "servo-fontconfig", "walkdir", "winapi 0.3.9", + "yeslogic-fontconfig-sys", ] [[package]] @@ -5930,27 +5935,6 @@ dependencies = [ "yaml-rust", ] -[[package]] -name = "servo-fontconfig" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c" -dependencies = [ - "libc", - "servo-fontconfig-sys", -] - -[[package]] -name = "servo-fontconfig-sys" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388" -dependencies = [ - "expat-sys", - "freetype-sys", - "pkg-config", -] - [[package]] name = "settings" version = "0.1.0" @@ -8542,6 +8526,18 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yeslogic-fontconfig-sys" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bbd69036d397ebbff671b1b8e4d918610c181c5a16073b96f984a38d08c386" +dependencies = [ + "const-cstr", + "dlib", + "once_cell", + "pkg-config", +] + [[package]] name = "zed" version = "0.87.0" diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 04862d1814..c1dc13084e 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -72,7 +72,7 @@ cocoa = "0.24" core-foundation = { version = "0.9.3", features = ["with-uuid"] } core-graphics = "0.22.3" core-text = "19.2" -font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "8eaf7a918eafa28b0a37dc759e2e0e7683fa24f1" } +font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18" } foreign-types = "0.3" log.workspace = true metal = "0.21.0" From aa89632286487304ed2a6626e786dd42233277eb Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 May 2023 11:40:30 -0700 Subject: [PATCH 3/7] Add diff hunks to the scroll bar --- crates/editor/src/element.rs | 49 ++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index c1710b7337..1d4aff39de 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1022,15 +1022,16 @@ impl EditorElement { let mut first_row_y_offset = 0.0; // Impose a minimum height on the scrollbar thumb + let row_height = height / max_row; let min_thumb_height = style.min_height_factor * cx.font_cache.line_height(self.style.text.font_size); - let thumb_height = (row_range.end - row_range.start) * height / max_row; + let thumb_height = (row_range.end - row_range.start) * row_height; if thumb_height < min_thumb_height { first_row_y_offset = (min_thumb_height - thumb_height) / 2.0; height -= min_thumb_height - thumb_height; } - let y_for_row = |row: f32| -> f32 { top + first_row_y_offset + row * height / max_row }; + let y_for_row = |row: f32| -> f32 { top + first_row_y_offset + row * row_height }; let thumb_top = y_for_row(row_range.start) - first_row_y_offset; let thumb_bottom = y_for_row(row_range.end) + first_row_y_offset; @@ -1044,6 +1045,50 @@ impl EditorElement { background: style.track.background_color, ..Default::default() }); + + let diff_style = cx.global::().theme.editor.diff.clone(); + for hunk in layout + .position_map + .snapshot + .buffer_snapshot + .git_diff_hunks_in_range(0..(max_row.floor() as u32), false) + { + let start_y = y_for_row(hunk.buffer_range.start as f32); + let mut end_y = if hunk.buffer_range.start == hunk.buffer_range.end { + y_for_row((hunk.buffer_range.end + 1) as f32) + } else { + y_for_row((hunk.buffer_range.end) as f32) + }; + + if end_y - start_y < 1. { + end_y = start_y + 1.; + } + let bounds = RectF::from_points(vec2f(left, start_y), vec2f(right, end_y)); + + let color = match hunk.status() { + DiffHunkStatus::Added => diff_style.inserted, + DiffHunkStatus::Modified => diff_style.modified, + DiffHunkStatus::Removed => diff_style.deleted, + }; + + let border = Border { + width: 1., + color: style.thumb.border.color, + overlay: false, + top: false, + right: true, + bottom: false, + left: true, + }; + + scene.push_quad(Quad { + bounds, + background: Some(color), + border, + corner_radius: style.thumb.corner_radius, + }) + } + scene.push_quad(Quad { bounds: thumb_bounds, border: style.thumb.border, From ae3394f4decb8ea5cfb305d2faf9bb7ebec86044 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 May 2023 14:09:26 -0700 Subject: [PATCH 4/7] Add scrollbars setting --- assets/settings/default.json | 11 +++++++++++ crates/editor/src/editor.rs | 9 +++++++++ crates/editor/src/element.rs | 10 +++++++++- crates/settings/src/settings.rs | 15 +++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 20d07acae0..05e79ae9cc 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -43,6 +43,17 @@ // 3. Draw all invisible symbols: // "all" "show_whitespaces": "selection", + // Whether to show the scrollbar in the editor. + // This setting can take four values: + // + // 1. Show the scrollbar if there's important information or + // follow the system's configured behavior (default): + // "auto" + // 2. Match the system's configured behavior: + // "system" + // 3. Always show the scrollbar: + // "always" + "show_scrollbars": "auto", // Whether the screen sharing icon is shown in the os status bar. "show_call_status_icon": true, // Whether to use language servers to provide code intelligence. diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 21d495d6ee..218daf08c4 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -516,6 +516,15 @@ pub struct EditorSnapshot { ongoing_scroll: OngoingScroll, } +impl EditorSnapshot { + fn has_scrollbar_info(&self) -> bool { + self.buffer_snapshot + .git_diff_hunks_in_range(0..self.max_point().row(), false) + .next() + .is_some() + } +} + #[derive(Clone, Debug)] struct SelectionHistoryEntry { selections: Arc<[Selection]>, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 1d4aff39de..e5fcb024c6 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2058,7 +2058,15 @@ impl Element for EditorElement { )); } - let show_scrollbars = editor.scroll_manager.scrollbars_visible(); + let show_scrollbars = match cx.global::().show_scrollbars { + settings::ShowScrollbars::Auto => { + snapshot.has_scrollbar_info() + || editor.scroll_manager.scrollbars_visible() + } + settings::ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(), + settings::ShowScrollbars::Always => true, + }; + let include_root = editor .project .as_ref() diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 7ba52fcb5e..284d2579a5 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -46,6 +46,7 @@ pub struct Settings { pub hover_popover_enabled: bool, pub show_completions_on_input: bool, pub show_call_status_icon: bool, + pub show_scrollbars: ShowScrollbars, pub vim_mode: bool, pub autosave: Autosave, pub default_dock_anchor: DockAnchor, @@ -68,6 +69,15 @@ pub struct Settings { pub base_keymap: BaseKeymap, } +#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)] +#[serde(rename_all = "snake_case")] +pub enum ShowScrollbars { + #[default] + Auto, + System, + Always, +} + #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)] pub enum BaseKeymap { #[default] @@ -390,6 +400,8 @@ pub struct SettingsFileContent { #[serde(default)] pub active_pane_magnification: Option, #[serde(default)] + pub show_scrollbars: Option, + #[serde(default)] pub cursor_blink: Option, #[serde(default)] pub confirm_quit: Option, @@ -547,6 +559,7 @@ impl Settings { features: Features { copilot: defaults.features.copilot.unwrap(), }, + show_scrollbars: defaults.show_scrollbars.unwrap(), } } @@ -598,6 +611,7 @@ impl Settings { merge(&mut self.autosave, data.autosave); merge(&mut self.default_dock_anchor, data.default_dock_anchor); merge(&mut self.base_keymap, data.base_keymap); + merge(&mut self.show_scrollbars, data.show_scrollbars); merge(&mut self.features.copilot, data.features.copilot); if let Some(copilot) = data.copilot { @@ -830,6 +844,7 @@ impl Settings { auto_update: true, base_keymap: Default::default(), features: Features { copilot: true }, + show_scrollbars: Default::default(), } } From 6cf439e73412bf332bfe358b845770d3f4813f78 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 May 2023 14:12:04 -0700 Subject: [PATCH 5/7] fmt --- crates/editor/src/element.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index e5fcb024c6..755c3091cb 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2060,8 +2060,7 @@ impl Element for EditorElement { let show_scrollbars = match cx.global::().show_scrollbars { settings::ShowScrollbars::Auto => { - snapshot.has_scrollbar_info() - || editor.scroll_manager.scrollbars_visible() + snapshot.has_scrollbar_info() || editor.scroll_manager.scrollbars_visible() } settings::ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(), settings::ShowScrollbars::Always => true, From 88bc55ddf5d31b9cffbb4b68d596a72b6c6153c6 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 May 2023 14:17:10 -0700 Subject: [PATCH 6/7] Add a dependency on rustfmt to the CI tests --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27af9e1164..a4176bd9b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,7 @@ jobs: runs-on: - self-hosted - test + needs: rustfmt env: RUSTFLAGS: -D warnings steps: From f4e99ecde4cd6c57c6e317f4ba5ccbcea6affcb9 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Wed, 17 May 2023 14:19:35 -0700 Subject: [PATCH 7/7] Add never option to scrollbar settings --- assets/settings/default.json | 2 ++ crates/editor/src/element.rs | 1 + crates/settings/src/settings.rs | 1 + 3 files changed, 4 insertions(+) diff --git a/assets/settings/default.json b/assets/settings/default.json index 05e79ae9cc..1395edca4a 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -53,6 +53,8 @@ // "system" // 3. Always show the scrollbar: // "always" + // 4. Never show the scrollbar: + // "never" "show_scrollbars": "auto", // Whether the screen sharing icon is shown in the os status bar. "show_call_status_icon": true, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 755c3091cb..e1e38f2e24 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2064,6 +2064,7 @@ impl Element for EditorElement { } settings::ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(), settings::ShowScrollbars::Always => true, + settings::ShowScrollbars::Never => false, }; let include_root = editor diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 284d2579a5..55598845c7 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -76,6 +76,7 @@ pub enum ShowScrollbars { Auto, System, Always, + Never, } #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]