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

[pull] main from zed-industries:main #56

Merged
merged 9 commits into from
Feb 12, 2025
46 changes: 41 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ rustc-demangle = "0.1.23"
rust-embed = { version = "8.4", features = ["include-exclude"] }
rustc-hash = "2.1.0"
rustls = { version = "0.23.22" }
rustls-native-certs = "0.8.0"
rustls-platform-verifier = "0.5.0"
schemars = { version = "0.8", features = ["impl_json_schema", "indexmap2"] }
semver = "1.0"
serde = { version = "1.0", features = ["derive", "rc"] }
Expand Down
5 changes: 5 additions & 0 deletions assets/icons/file_icons/file_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
"coffee": "coffeescript",
"conf": "settings",
"cpp": "cpp",
"cs": "csharp",
"css": "css",
"csv": "storage",
"cxx": "cpp",
"cts": "typescript",
"ctsx": "react",
"cue": "cue",
"dart": "dart",
"dat": "storage",
"db": "storage",
Expand Down Expand Up @@ -66,6 +68,7 @@
"gitattributes": "vcs",
"gitignore": "vcs",
"gitkeep": "vcs",
"gitlab-ci.yml": "gitlab",
"gitmodules": "vcs",
"TAG_EDITMSG": "vcs",
"MERGE_MSG": "vcs",
Expand Down Expand Up @@ -113,6 +116,7 @@
"lockb": "bun",
"log": "log",
"lua": "lua",
"luau": "luau",
"m4a": "audio",
"m4v": "video",
"markdown": "markdown",
Expand Down Expand Up @@ -188,6 +192,7 @@
"scss": "sass",
"sdf": "storage",
"sh": "terminal",
"sol": "solidity",
"sql": "storage",
"sqlite": "storage",
"stylelint.config.cjs": "stylelint",
Expand Down
8 changes: 4 additions & 4 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,11 @@
],
// When to show edit predictions previews in buffer.
// This setting takes two possible values:
// 1. Display inline when holding modifier key (alt by default).
// "mode": "auto"
// 2. Display inline when there are no language server completions available.
// 1. Display inline when there are no language server completions available.
// "mode": "eager_preview"
"mode": "auto"
// 2. Display inline when holding modifier key (alt by default).
// "mode": "auto"
"mode": "eager_preview"
},
// Settings specific to journaling
"journal": {
Expand Down
2 changes: 0 additions & 2 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ postage.workspace = true
rand.workspace = true
release_channel.workspace = true
rpc = { workspace = true, features = ["gpui"] }
rustls-native-certs.workspace = true
rustls.workspace = true
schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand Down
17 changes: 1 addition & 16 deletions crates/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ pub fn init_settings(cx: &mut App) {
}

pub fn init(client: &Arc<Client>, cx: &mut App) {
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();

let client = Arc::downgrade(client);
cx.on_action({
let client = client.clone();
Expand Down Expand Up @@ -1126,24 +1124,11 @@ impl Client {

match url_scheme {
Https => {
let client_config = {
let mut root_store = rustls::RootCertStore::empty();

let root_certs = rustls_native_certs::load_native_certs();
for error in root_certs.errors {
log::warn!("error loading native certs: {:?}", error);
}
root_store.add_parsable_certificates(root_certs.certs);
rustls::ClientConfig::builder()
.with_root_certificates(root_store)
.with_no_client_auth()
};

let (stream, _) =
async_tungstenite::async_tls::client_async_tls_with_connector(
request,
stream,
Some(client_config.into()),
Some(http_client::tls_config().into()),
)
.await?;
Ok(Connection::new(
Expand Down
93 changes: 88 additions & 5 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,11 +709,12 @@ pub struct Editor {
/// Used to prevent flickering as the user types while the menu is open
stale_inline_completion_in_menu: Option<InlineCompletionState>,
edit_prediction_settings: EditPredictionSettings,
edit_prediction_cursor_on_leading_whitespace: bool,
inline_completions_hidden_for_vim_mode: bool,
show_inline_completions_override: Option<bool>,
menu_inline_completions_policy: MenuInlineCompletionsPolicy,
edit_prediction_preview: EditPredictionPreview,
edit_prediction_cursor_on_leading_whitespace: bool,
edit_prediction_requires_modifier_in_leading_space: bool,
inlay_hint_cache: InlayHintCache,
next_inlay_id: usize,
_subscriptions: Vec<Subscription>,
Expand Down Expand Up @@ -1425,6 +1426,7 @@ impl Editor {
menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider,
edit_prediction_settings: EditPredictionSettings::Disabled,
edit_prediction_cursor_on_leading_whitespace: false,
edit_prediction_requires_modifier_in_leading_space: true,
custom_context_menu: None,
show_git_blame_gutter: false,
show_git_blame_inline: false,
Expand Down Expand Up @@ -1573,7 +1575,7 @@ impl Editor {
|| self.edit_prediction_requires_modifier()
// Require modifier key when the cursor is on leading whitespace, to allow `tab`
// bindings to insert tab characters.
|| self.edit_prediction_cursor_on_leading_whitespace
|| (self.edit_prediction_requires_modifier_in_leading_space && self.edit_prediction_cursor_on_leading_whitespace)
{
key_context.add(EDIT_PREDICTION_REQUIRES_MODIFIER_KEY_CONTEXT);
}
Expand Down Expand Up @@ -2137,6 +2139,7 @@ impl Editor {
self.refresh_document_highlights(cx);
refresh_matching_bracket_highlights(self, window, cx);
self.update_visible_inline_completion(window, cx);
self.edit_prediction_requires_modifier_in_leading_space = true;
linked_editing_ranges::refresh_linked_ranges(self, window, cx);
if self.git_blame_inline_enabled {
self.start_inline_blame_timer(window, cx);
Expand Down Expand Up @@ -5013,6 +5016,8 @@ impl Editor {
cx.notify();
}
}

self.edit_prediction_requires_modifier_in_leading_space = false;
}

pub fn accept_partial_inline_completion(
Expand Down Expand Up @@ -5648,6 +5653,75 @@ impl Editor {
}
}

fn render_edit_prediction_accept_keybind(&self, window: &mut Window, cx: &App) -> Option<Div> {
let accept_binding = self.accept_edit_prediction_keybind(window, cx);
let accept_keystroke = accept_binding.keystroke()?;
let colors = cx.theme().colors();
let accent_color = colors.text_accent;
let editor_bg_color = colors.editor_background;
let bg_color = editor_bg_color.blend(accent_color.opacity(0.1));

h_flex()
.px_0p5()
.gap_1()
.bg(bg_color)
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
.text_size(TextSize::XSmall.rems(cx))
.children(ui::render_modifiers(
&accept_keystroke.modifiers,
PlatformStyle::platform(),
Some(if accept_keystroke.modifiers == window.modifiers() {
Color::Accent
} else {
Color::Muted
}),
Some(IconSize::XSmall.rems().into()),
false,
))
.child(accept_keystroke.key.clone())
.into()
}

fn render_edit_prediction_line_popover(
&self,
label: impl Into<SharedString>,
icon: Option<IconName>,
window: &mut Window,
cx: &App,
) -> Option<Div> {
let bg_color = Self::edit_prediction_line_popover_bg_color(cx);

let padding_right = if icon.is_some() { px(4.) } else { px(8.) };

let result = h_flex()
.gap_1()
.border_1()
.rounded_lg()
.shadow_sm()
.bg(bg_color)
.border_color(cx.theme().colors().text_accent.opacity(0.4))
.py_0p5()
.pl_1()
.pr(padding_right)
.children(self.render_edit_prediction_accept_keybind(window, cx))
.child(Label::new(label).size(LabelSize::Small))
.when_some(icon, |element, icon| {
element.child(
div()
.mt(px(1.5))
.child(Icon::new(icon).size(IconSize::Small)),
)
});

Some(result)
}

fn edit_prediction_line_popover_bg_color(cx: &App) -> Hsla {
let accent_color = cx.theme().colors().text_accent;
let editor_bg_color = cx.theme().colors().editor_background;
editor_bg_color.blend(accent_color.opacity(0.1))
}

#[allow(clippy::too_many_arguments)]
fn render_edit_prediction_cursor_popover(
&self,
Expand Down Expand Up @@ -5788,18 +5862,26 @@ impl Editor {
.min_w(min_width)
.max_w(max_width)
.flex_1()
.px_2()
.elevation_2(cx)
.border_color(cx.theme().colors().border)
.child(div().py_1().overflow_hidden().child(completion))
.child(
div()
.flex_1()
.py_1()
.px_2()
.overflow_hidden()
.child(completion),
)
.child(
h_flex()
.h_full()
.border_l_1()
.rounded_r_lg()
.border_color(cx.theme().colors().border)
.bg(Self::edit_prediction_line_popover_bg_color(cx))
.gap_1()
.py_1()
.pl_2()
.px_2()
.child(
h_flex()
.font(theme::ThemeSettings::get_global(cx).buffer_font.clone())
Expand Down Expand Up @@ -14548,6 +14630,7 @@ impl Editor {
}

self.hide_context_menu(window, cx);
self.discard_inline_completion(false, cx);
cx.emit(EditorEvent::Blurred);
cx.notify();
}
Expand Down
Loading