Compare commits
12 Commits
simplify-e
...
v0.128.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7380ab8a1a | ||
|
|
f3e557d106 | ||
|
|
99775968c1 | ||
|
|
3e2590842d | ||
|
|
9ed7822278 | ||
|
|
ff0164eeb6 | ||
|
|
42967551c7 | ||
|
|
ddc2844949 | ||
|
|
646b493b9d | ||
|
|
8ca7b0dded | ||
|
|
383473c94b | ||
|
|
77b71879fe |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -12541,7 +12541,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zed"
|
||||
version = "0.128.0"
|
||||
version = "0.128.3"
|
||||
dependencies = [
|
||||
"activity_indicator",
|
||||
"anyhow",
|
||||
|
||||
@@ -97,13 +97,8 @@ impl LanguageModel {
|
||||
|
||||
pub fn max_token_count(&self) -> usize {
|
||||
match self {
|
||||
LanguageModel::OpenAi(model) => tiktoken_rs::model::get_context_size(model.id()),
|
||||
LanguageModel::ZedDotDev(model) => match model {
|
||||
ZedDotDevModel::GptThreePointFiveTurbo
|
||||
| ZedDotDevModel::GptFour
|
||||
| ZedDotDevModel::GptFourTurbo => tiktoken_rs::model::get_context_size(model.id()),
|
||||
ZedDotDevModel::Custom(_) => 30720, // TODO: Base this on the selected model.
|
||||
},
|
||||
LanguageModel::OpenAi(model) => model.max_token_count(),
|
||||
LanguageModel::ZedDotDev(model) => model.max_token_count(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,15 @@ impl ZedDotDevModel {
|
||||
Self::Custom(id) => id.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_token_count(&self) -> usize {
|
||||
match self {
|
||||
Self::GptThreePointFiveTurbo => 2048,
|
||||
Self::GptFour => 4096,
|
||||
Self::GptFourTurbo => 128000,
|
||||
Self::Custom(_) => 4096, // TODO: Make this configurable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema)]
|
||||
|
||||
@@ -194,9 +194,8 @@ impl Render for CopilotCodeVerification {
|
||||
.on_action(cx.listener(|_, _: &menu::Cancel, cx| {
|
||||
cx.emit(DismissEvent);
|
||||
}))
|
||||
.capture_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, cx| {
|
||||
.on_any_mouse_down(cx.listener(|this, _: &MouseDownEvent, cx| {
|
||||
cx.focus(&this.focus_handle);
|
||||
cx.stop_propagation();
|
||||
}))
|
||||
.child(
|
||||
svg()
|
||||
|
||||
@@ -898,9 +898,7 @@ impl CompletionsMenu {
|
||||
.max_w(px(640.))
|
||||
.w(px(500.))
|
||||
.overflow_y_scroll()
|
||||
// Prevent a mouse down on documentation from being propagated to the editor,
|
||||
// because that would move the cursor.
|
||||
.on_mouse_down(MouseButton::Left, |_, cx| cx.stop_propagation())
|
||||
.occlude()
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@@ -989,6 +987,7 @@ impl CompletionsMenu {
|
||||
.collect()
|
||||
},
|
||||
)
|
||||
.occlude()
|
||||
.max_h(max_height)
|
||||
.track_scroll(self.scroll_handle.clone())
|
||||
.with_width_from_item(widest_completion_ix);
|
||||
@@ -1212,6 +1211,7 @@ impl CodeActionsMenu {
|
||||
.px_2()
|
||||
.py_1()
|
||||
.max_h(max_height)
|
||||
.occlude()
|
||||
.track_scroll(self.scroll_handle.clone())
|
||||
.with_width_from_item(
|
||||
self.actions
|
||||
|
||||
@@ -424,8 +424,9 @@ impl ExtensionStore {
|
||||
operation: ExtensionOperation,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
let extensions_dir = self.extensions_dir();
|
||||
let extension_dir = self.installed_dir.join(extension_id.as_ref());
|
||||
let http_client = self.http_client.clone();
|
||||
let fs = self.fs.clone();
|
||||
|
||||
match self.outstanding_operations.entry(extension_id.clone()) {
|
||||
hash_map::Entry::Occupied(_) => return,
|
||||
@@ -450,11 +451,19 @@ impl ExtensionStore {
|
||||
.get(&url, Default::default(), true)
|
||||
.await
|
||||
.map_err(|err| anyhow!("error downloading extension: {}", err))?;
|
||||
|
||||
fs.remove_dir(
|
||||
&extension_dir,
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
ignore_if_not_exists: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut()));
|
||||
let archive = Archive::new(decompressed_bytes);
|
||||
archive
|
||||
.unpack(extensions_dir.join(extension_id.as_ref()))
|
||||
.await?;
|
||||
archive.unpack(extension_dir).await?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.reload(Some(extension_id.clone()), cx)
|
||||
})?
|
||||
@@ -519,7 +528,7 @@ impl ExtensionStore {
|
||||
}
|
||||
|
||||
pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) {
|
||||
let extensions_dir = self.extensions_dir();
|
||||
let extension_dir = self.installed_dir.join(extension_id.as_ref());
|
||||
let fs = self.fs.clone();
|
||||
|
||||
match self.outstanding_operations.entry(extension_id.clone()) {
|
||||
@@ -542,7 +551,7 @@ impl ExtensionStore {
|
||||
});
|
||||
|
||||
fs.remove_dir(
|
||||
&extensions_dir.join(extension_id.as_ref()),
|
||||
&extension_dir,
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
ignore_if_not_exists: true,
|
||||
|
||||
@@ -415,8 +415,26 @@ impl Element for InteractiveText {
|
||||
state: &mut Self::BeforeLayout,
|
||||
cx: &mut ElementContext,
|
||||
) -> Hitbox {
|
||||
self.text.after_layout(bounds, state, cx);
|
||||
cx.insert_hitbox(bounds, false)
|
||||
cx.with_element_state::<InteractiveTextState, _>(
|
||||
Some(self.element_id.clone()),
|
||||
|interactive_state, cx| {
|
||||
let interactive_state = interactive_state
|
||||
.map(|interactive_state| interactive_state.unwrap_or_default());
|
||||
|
||||
if let Some(interactive_state) = interactive_state.as_ref() {
|
||||
if let Some(active_tooltip) = interactive_state.active_tooltip.borrow().as_ref()
|
||||
{
|
||||
if let Some(tooltip) = active_tooltip.tooltip.clone() {
|
||||
cx.set_tooltip(tooltip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.text.after_layout(bounds, state, cx);
|
||||
let hitbox = cx.insert_hitbox(bounds, false);
|
||||
(hitbox, interactive_state)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn paint(
|
||||
@@ -557,16 +575,6 @@ impl Element for InteractiveText {
|
||||
cx.on_mouse_event(move |_: &MouseDownEvent, _, _| {
|
||||
active_tooltip.take();
|
||||
});
|
||||
|
||||
if let Some(tooltip) = interactive_state
|
||||
.active_tooltip
|
||||
.clone()
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.and_then(|at| at.tooltip.clone())
|
||||
{
|
||||
cx.set_tooltip(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
self.text.paint(bounds, text_state, &mut (), cx);
|
||||
|
||||
@@ -48,7 +48,6 @@ where
|
||||
interactivity: Interactivity {
|
||||
element_id: Some(id),
|
||||
base_style: Box::new(base_style),
|
||||
occlude_mouse: true,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
location: Some(*core::panic::Location::caller()),
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::{
|
||||
use util::{
|
||||
async_maybe,
|
||||
fs::remove_matching,
|
||||
github::{github_release_with_tag, GitHubLspBinaryVersion},
|
||||
github::{build_tarball_url, GitHubLspBinaryVersion},
|
||||
ResultExt,
|
||||
};
|
||||
|
||||
@@ -227,9 +227,14 @@ pub struct EsLintLspAdapter {
|
||||
}
|
||||
|
||||
impl EsLintLspAdapter {
|
||||
const CURRENT_VERSION: &'static str = "release/2.4.4";
|
||||
|
||||
const SERVER_PATH: &'static str = "vscode-eslint/server/out/eslintServer.js";
|
||||
const SERVER_NAME: &'static str = "eslint";
|
||||
|
||||
const FLAT_CONFIG_FILE_NAMES: &'static [&'static str] =
|
||||
&["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs"];
|
||||
|
||||
pub fn new(node: Arc<dyn NodeRuntime>) -> Self {
|
||||
EsLintLspAdapter { node }
|
||||
}
|
||||
@@ -266,6 +271,9 @@ impl LspAdapter for EsLintLspAdapter {
|
||||
}
|
||||
|
||||
let node_path = eslint_user_settings.get("nodePath").unwrap_or(&Value::Null);
|
||||
let use_flat_config = Self::FLAT_CONFIG_FILE_NAMES
|
||||
.iter()
|
||||
.any(|file| workspace_root.join(file).is_file());
|
||||
|
||||
json!({
|
||||
"": {
|
||||
@@ -282,7 +290,7 @@ impl LspAdapter for EsLintLspAdapter {
|
||||
"problems": {},
|
||||
"codeActionOnSave": code_action_on_save,
|
||||
"experimental": {
|
||||
"useFlatConfig": workspace_root.join("eslint.config.js").is_file(),
|
||||
"useFlatConfig": use_flat_config,
|
||||
},
|
||||
}
|
||||
})
|
||||
@@ -294,19 +302,13 @@ impl LspAdapter for EsLintLspAdapter {
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
&self,
|
||||
delegate: &dyn LspAdapterDelegate,
|
||||
_delegate: &dyn LspAdapterDelegate,
|
||||
) -> Result<Box<dyn 'static + Send + Any>> {
|
||||
// We're using this hardcoded release tag, because ESLint's API changed with
|
||||
// >= 2.3 and we haven't upgraded yet.
|
||||
let release = github_release_with_tag(
|
||||
"microsoft/vscode-eslint",
|
||||
"release/2.2.20-Insider",
|
||||
delegate.http_client(),
|
||||
)
|
||||
.await?;
|
||||
let url = build_tarball_url("microsoft/vscode-eslint", Self::CURRENT_VERSION)?;
|
||||
|
||||
Ok(Box::new(GitHubLspBinaryVersion {
|
||||
name: release.tag_name,
|
||||
url: release.tarball_url,
|
||||
name: Self::CURRENT_VERSION.into(),
|
||||
url,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,14 @@ impl Model {
|
||||
Self::FourTurbo => "gpt-4-turbo",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_token_count(&self) -> usize {
|
||||
match self {
|
||||
Model::ThreePointFiveTurbo => 4096,
|
||||
Model::Four => 8192,
|
||||
Model::FourTurbo => 128000,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
|
||||
@@ -183,7 +183,7 @@ async function handleMessage(message, prettier) {
|
||||
...resolvedConfig,
|
||||
plugins,
|
||||
parser: params.options.parser,
|
||||
path: params.options.filepath,
|
||||
filepath: params.options.filepath,
|
||||
};
|
||||
process.stderr.write(
|
||||
`Resolved config: ${JSON.stringify(resolvedConfig)}, will format file '${
|
||||
|
||||
@@ -76,78 +76,33 @@ pub async fn latest_github_release(
|
||||
.ok_or(anyhow!("Failed to find a release"))
|
||||
}
|
||||
|
||||
pub async fn github_release_with_tag(
|
||||
repo_name_with_owner: &str,
|
||||
tag: &str,
|
||||
http: Arc<dyn HttpClient>,
|
||||
) -> Result<GithubRelease, anyhow::Error> {
|
||||
let url = build_tagged_release_url(repo_name_with_owner, tag)?;
|
||||
let mut response = http
|
||||
.get(&url, Default::default(), true)
|
||||
.await
|
||||
.with_context(|| format!("error fetching release {} of {}", tag, repo_name_with_owner))?;
|
||||
|
||||
let mut body = Vec::new();
|
||||
response
|
||||
.body_mut()
|
||||
.read_to_end(&mut body)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"error reading response body for release {} of {}",
|
||||
tag, repo_name_with_owner
|
||||
)
|
||||
})?;
|
||||
|
||||
if response.status().is_client_error() {
|
||||
let text = String::from_utf8_lossy(body.as_slice());
|
||||
bail!(
|
||||
"status error {}, response: {text:?}",
|
||||
response.status().as_u16()
|
||||
);
|
||||
}
|
||||
|
||||
match serde_json::from_slice::<GithubRelease>(body.as_slice()) {
|
||||
Ok(release) => Ok(release),
|
||||
|
||||
Err(err) => {
|
||||
log::error!("Error deserializing: {:?}", err);
|
||||
log::error!(
|
||||
"GitHub API response text: {:?}",
|
||||
String::from_utf8_lossy(body.as_slice())
|
||||
);
|
||||
Err(anyhow!(
|
||||
"error deserializing release {} of {}",
|
||||
tag,
|
||||
repo_name_with_owner
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_tagged_release_url(repo_name_with_owner: &str, tag: &str) -> Result<String> {
|
||||
pub fn build_tarball_url(repo_name_with_owner: &str, tag: &str) -> Result<String> {
|
||||
let mut url = Url::parse(&format!(
|
||||
"https://api.github.com/repos/{repo_name_with_owner}/releases/tags"
|
||||
"https://github.com/{repo_name_with_owner}/archive/refs/tags",
|
||||
))?;
|
||||
// We're pushing this here, because tags may contain `/` and other characters
|
||||
// that need to be escaped.
|
||||
let tarball_filename = format!("{}.tar.gz", tag);
|
||||
url.path_segments_mut()
|
||||
.map_err(|_| anyhow!("cannot modify url path segments"))?
|
||||
.push(tag);
|
||||
.push(&tarball_filename);
|
||||
Ok(url.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::build_tagged_release_url;
|
||||
use crate::github::build_tarball_url;
|
||||
|
||||
#[test]
|
||||
fn test_build_tagged_release_url() {
|
||||
let tag = "release/2.2.20-Insider";
|
||||
fn test_build_tarball_url() {
|
||||
let tag = "release/2.3.5";
|
||||
let repo_name_with_owner = "microsoft/vscode-eslint";
|
||||
|
||||
let have = build_tagged_release_url(repo_name_with_owner, tag).unwrap();
|
||||
let have = build_tarball_url(repo_name_with_owner, tag).unwrap();
|
||||
|
||||
assert_eq!(have, "https://api.github.com/repos/microsoft/vscode-eslint/releases/tags/release%2F2.2.20-Insider");
|
||||
assert_eq!(
|
||||
have,
|
||||
"https://github.com/microsoft/vscode-eslint/archive/refs/tags/release%2F2.3.5.tar.gz"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
description = "The fast, collaborative code editor."
|
||||
edition = "2021"
|
||||
name = "zed"
|
||||
version = "0.128.0"
|
||||
version = "0.128.3"
|
||||
publish = false
|
||||
license = "GPL-3.0-or-later"
|
||||
authors = ["Zed Team <hi@zed.dev>"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
dev
|
||||
stable
|
||||
Reference in New Issue
Block a user