mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Add streaming_diff
crate (#23264)
This PR extracts the streaming diff implementation to its own `streaming_diff` crate. It was duplicated between `assistant` and `assistant2`, but their implementations were exactly the same (and I don't see a reason why they would need to diverge). Release Notes: - N/A
This commit is contained in:
parent
4d22f7e529
commit
24495f09f9
12 changed files with 41 additions and 1113 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -405,7 +405,6 @@ dependencies = [
|
|||
"menu",
|
||||
"multi_buffer",
|
||||
"open_ai",
|
||||
"ordered-float 2.10.1",
|
||||
"parking_lot",
|
||||
"paths",
|
||||
"picker",
|
||||
|
@ -428,6 +427,7 @@ dependencies = [
|
|||
"similar",
|
||||
"smallvec",
|
||||
"smol",
|
||||
"streaming_diff",
|
||||
"strum",
|
||||
"telemetry",
|
||||
"telemetry_events",
|
||||
|
@ -479,7 +479,6 @@ dependencies = [
|
|||
"markdown",
|
||||
"menu",
|
||||
"multi_buffer",
|
||||
"ordered-float 2.10.1",
|
||||
"parking_lot",
|
||||
"picker",
|
||||
"project",
|
||||
|
@ -492,6 +491,7 @@ dependencies = [
|
|||
"settings",
|
||||
"similar",
|
||||
"smol",
|
||||
"streaming_diff",
|
||||
"telemetry_events",
|
||||
"terminal",
|
||||
"terminal_view",
|
||||
|
@ -12347,6 +12347,16 @@ dependencies = [
|
|||
"ui",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "streaming_diff"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ordered-float 2.10.1",
|
||||
"rand 0.8.5",
|
||||
"rope",
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strict-num"
|
||||
version = "0.1.1"
|
||||
|
|
|
@ -116,6 +116,7 @@ members = [
|
|||
"crates/sqlez_macros",
|
||||
"crates/story",
|
||||
"crates/storybook",
|
||||
"crates/streaming_diff",
|
||||
"crates/sum_tree",
|
||||
"crates/supermaven",
|
||||
"crates/supermaven_api",
|
||||
|
@ -307,6 +308,7 @@ sqlez = { path = "crates/sqlez" }
|
|||
sqlez_macros = { path = "crates/sqlez_macros" }
|
||||
story = { path = "crates/story" }
|
||||
storybook = { path = "crates/storybook" }
|
||||
streaming_diff = { path = "crates/streaming_diff" }
|
||||
sum_tree = { path = "crates/sum_tree" }
|
||||
supermaven = { path = "crates/supermaven" }
|
||||
supermaven_api = { path = "crates/supermaven_api" }
|
||||
|
|
|
@ -51,7 +51,6 @@ lsp.workspace = true
|
|||
menu.workspace = true
|
||||
multi_buffer.workspace = true
|
||||
open_ai = { workspace = true, features = ["schemars"] }
|
||||
ordered-float.workspace = true
|
||||
parking_lot.workspace = true
|
||||
paths.workspace = true
|
||||
picker.workspace = true
|
||||
|
@ -71,6 +70,7 @@ settings.workspace = true
|
|||
similar.workspace = true
|
||||
smallvec.workspace = true
|
||||
smol.workspace = true
|
||||
streaming_diff.workspace = true
|
||||
strum.workspace = true
|
||||
telemetry.workspace = true
|
||||
telemetry_events.workspace = true
|
||||
|
|
|
@ -9,7 +9,6 @@ mod prompt_library;
|
|||
mod slash_command;
|
||||
pub(crate) mod slash_command_picker;
|
||||
pub mod slash_command_settings;
|
||||
mod streaming_diff;
|
||||
mod terminal_inline_assistant;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
@ -39,7 +38,6 @@ pub use crate::context_store::*;
|
|||
pub(crate) use crate::inline_assistant::*;
|
||||
pub use crate::patch::*;
|
||||
use crate::slash_command_settings::SlashCommandSettings;
|
||||
pub(crate) use crate::streaming_diff::*;
|
||||
|
||||
actions!(
|
||||
assistant,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::{
|
||||
humanize_token_count, AssistantPanel, AssistantPanelEvent, CharOperation,
|
||||
CycleNextInlineAssist, CyclePreviousInlineAssist, LineDiff, LineOperation, RequestType,
|
||||
StreamingDiff,
|
||||
humanize_token_count, AssistantPanel, AssistantPanelEvent, CycleNextInlineAssist,
|
||||
CyclePreviousInlineAssist, RequestType,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _, Result};
|
||||
use assistant_settings::AssistantSettings;
|
||||
|
@ -56,6 +55,7 @@ use std::{
|
|||
task::{self, Poll},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
||||
use terminal_view::terminal_panel::TerminalPanel;
|
||||
use text::{OffsetRangeExt, ToPoint as _};
|
||||
|
|
|
@ -43,7 +43,6 @@ lsp.workspace = true
|
|||
markdown.workspace = true
|
||||
menu.workspace = true
|
||||
multi_buffer.workspace = true
|
||||
ordered-float.workspace = true
|
||||
parking_lot.workspace = true
|
||||
picker.workspace = true
|
||||
project.workspace = true
|
||||
|
@ -55,6 +54,7 @@ serde_json.workspace = true
|
|||
settings.workspace = true
|
||||
similar.workspace = true
|
||||
smol.workspace = true
|
||||
streaming_diff.workspace = true
|
||||
telemetry_events.workspace = true
|
||||
terminal.workspace = true
|
||||
terminal_view.workspace = true
|
||||
|
|
|
@ -9,7 +9,6 @@ mod context_strip;
|
|||
mod inline_assistant;
|
||||
mod inline_prompt_editor;
|
||||
mod message_editor;
|
||||
mod streaming_diff;
|
||||
mod terminal_codegen;
|
||||
mod terminal_inline_assistant;
|
||||
mod thread;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::context::attach_context_to_message;
|
||||
use crate::context_store::ContextStore;
|
||||
use crate::inline_prompt_editor::CodegenStatus;
|
||||
use crate::streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||
use anyhow::{Context as _, Result};
|
||||
use client::telemetry::Telemetry;
|
||||
use collections::HashSet;
|
||||
|
@ -29,6 +28,7 @@ use std::{
|
|||
task::{self, Poll},
|
||||
time::Instant,
|
||||
};
|
||||
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
|
||||
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
|
||||
|
||||
pub struct BufferCodegen {
|
||||
|
|
File diff suppressed because it is too large
Load diff
20
crates/streaming_diff/Cargo.toml
Normal file
20
crates/streaming_diff/Cargo.toml
Normal file
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "streaming_diff"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "GPL-3.0-or-later"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/streaming_diff.rs"
|
||||
|
||||
[dependencies]
|
||||
ordered-float.workspace = true
|
||||
rope.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
rand.workspace = true
|
||||
util = { workspace = true, features = ["test-support"] }
|
1
crates/streaming_diff/LICENSE-GPL
Symbolic link
1
crates/streaming_diff/LICENSE-GPL
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../LICENSE-GPL
|
Loading…
Reference in a new issue