Compare commits
6 Commits
show-lua-s
...
faster_win
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a119073058 | ||
|
|
fb0453d60d | ||
|
|
857572695d | ||
|
|
b3b5d79252 | ||
|
|
e055852d3d | ||
|
|
81d0fdaed1 |
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -490,7 +490,6 @@ dependencies = [
|
|||||||
"prompt_store",
|
"prompt_store",
|
||||||
"proto",
|
"proto",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"rich_text",
|
|
||||||
"rope",
|
"rope",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ members = [
|
|||||||
"crates/assistant",
|
"crates/assistant",
|
||||||
"crates/assistant2",
|
"crates/assistant2",
|
||||||
"crates/assistant_context_editor",
|
"crates/assistant_context_editor",
|
||||||
"crates/assistant_scripting",
|
|
||||||
"crates/assistant_settings",
|
"crates/assistant_settings",
|
||||||
"crates/assistant_slash_command",
|
"crates/assistant_slash_command",
|
||||||
"crates/assistant_slash_commands",
|
"crates/assistant_slash_commands",
|
||||||
@@ -119,6 +118,7 @@ members = [
|
|||||||
"crates/rope",
|
"crates/rope",
|
||||||
"crates/rpc",
|
"crates/rpc",
|
||||||
"crates/schema_generator",
|
"crates/schema_generator",
|
||||||
|
"crates/assistant_scripting",
|
||||||
"crates/search",
|
"crates/search",
|
||||||
"crates/semantic_index",
|
"crates/semantic_index",
|
||||||
"crates/semantic_version",
|
"crates/semantic_version",
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ test-support = [
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
assistant_context_editor.workspace = true
|
assistant_context_editor.workspace = true
|
||||||
assistant_scripting.workspace = true
|
|
||||||
assistant_settings.workspace = true
|
assistant_settings.workspace = true
|
||||||
assistant_slash_command.workspace = true
|
assistant_slash_command.workspace = true
|
||||||
assistant_tool.workspace = true
|
assistant_tool.workspace = true
|
||||||
@@ -64,7 +63,7 @@ serde.workspace = true
|
|||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
rich_text.workspace = true
|
assistant_scripting.workspace = true
|
||||||
streaming_diff.workspace = true
|
streaming_diff.workspace = true
|
||||||
telemetry_events.workspace = true
|
telemetry_events.workspace = true
|
||||||
terminal.workspace = true
|
terminal.workspace = true
|
||||||
@@ -83,8 +82,8 @@ zed_actions.workspace = true
|
|||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
editor = { workspace = true, features = ["test-support"] }
|
editor = { workspace = true, features = ["test-support"] }
|
||||||
gpui = { workspace = true, "features" = ["test-support"] }
|
gpui = { workspace = true, "features" = ["test-support"] }
|
||||||
indoc.workspace = true
|
|
||||||
language = { workspace = true, "features" = ["test-support"] }
|
language = { workspace = true, "features" = ["test-support"] }
|
||||||
language_model = { workspace = true, "features" = ["test-support"] }
|
language_model = { workspace = true, "features" = ["test-support"] }
|
||||||
project = { workspace = true, features = ["test-support"] }
|
project = { workspace = true, features = ["test-support"] }
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
|
indoc.workspace = true
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use assistant_scripting::{ScriptId, ScriptState};
|
use assistant_scripting::{ScriptId, ScriptState};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
use futures::FutureExt;
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
list, AbsoluteLength, AnyElement, App, ClickEvent, DefiniteLength, EdgesRefinement, Empty,
|
list, AbsoluteLength, AnyElement, App, ClickEvent, DefiniteLength, EdgesRefinement, Empty,
|
||||||
Entity, Focusable, Length, ListAlignment, ListOffset, ListState, StyleRefinement, Subscription,
|
Entity, Focusable, Length, ListAlignment, ListOffset, ListState, StyleRefinement, Subscription,
|
||||||
@@ -11,8 +12,6 @@ use language::{Buffer, LanguageRegistry};
|
|||||||
use language_model::{LanguageModelRegistry, LanguageModelToolUseId, Role};
|
use language_model::{LanguageModelRegistry, LanguageModelToolUseId, Role};
|
||||||
use markdown::{Markdown, MarkdownStyle};
|
use markdown::{Markdown, MarkdownStyle};
|
||||||
use settings::Settings as _;
|
use settings::Settings as _;
|
||||||
use std::ops::Range;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
use ui::{prelude::*, Disclosure, KeyBinding};
|
use ui::{prelude::*, Disclosure, KeyBinding};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
@@ -22,8 +21,6 @@ use crate::thread::{MessageId, RequestKind, Thread, ThreadError, ThreadEvent};
|
|||||||
use crate::thread_store::ThreadStore;
|
use crate::thread_store::ThreadStore;
|
||||||
use crate::tool_use::{ToolUse, ToolUseStatus};
|
use crate::tool_use::{ToolUse, ToolUseStatus};
|
||||||
use crate::ui::ContextPill;
|
use crate::ui::ContextPill;
|
||||||
use gpui::{HighlightStyle, StyledText};
|
|
||||||
use rich_text::{self, Highlight};
|
|
||||||
|
|
||||||
pub struct ActiveThread {
|
pub struct ActiveThread {
|
||||||
workspace: WeakEntity<Workspace>,
|
workspace: WeakEntity<Workspace>,
|
||||||
@@ -812,63 +809,11 @@ impl ActiveThread {
|
|||||||
let stdout = script.stdout_snapshot();
|
let stdout = script.stdout_snapshot();
|
||||||
let error = script.error();
|
let error = script.error();
|
||||||
|
|
||||||
let lua_language =
|
|
||||||
async { self.language_registry.language_for_name("Lua").await.ok() }
|
|
||||||
.now_or_never()
|
|
||||||
.flatten();
|
|
||||||
|
|
||||||
let source_display = if let Some(lua_language) = &lua_language {
|
|
||||||
let mut highlights = Vec::new();
|
|
||||||
let mut buf = String::new();
|
|
||||||
|
|
||||||
rich_text::render_code(
|
|
||||||
&mut buf,
|
|
||||||
&mut highlights,
|
|
||||||
&script.source,
|
|
||||||
lua_language,
|
|
||||||
);
|
|
||||||
|
|
||||||
let theme = cx.theme();
|
|
||||||
let gpui_highlights: Vec<(Range<usize>, HighlightStyle)> = highlights
|
|
||||||
.iter()
|
|
||||||
.map(|(range, highlight)| {
|
|
||||||
let style = match highlight {
|
|
||||||
Highlight::Code => Default::default(),
|
|
||||||
Highlight::Id(id) => {
|
|
||||||
id.style(theme.syntax()).unwrap_or_default()
|
|
||||||
}
|
|
||||||
Highlight::InlineCode(_) => Default::default(),
|
|
||||||
Highlight::Highlight(highlight) => *highlight,
|
|
||||||
_ => HighlightStyle::default(),
|
|
||||||
};
|
|
||||||
(range.clone(), style)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
StyledText::new(buf)
|
|
||||||
.with_highlights(gpui_highlights)
|
|
||||||
.into_any_element()
|
|
||||||
} else {
|
|
||||||
Label::new(script.source.clone())
|
|
||||||
.size(LabelSize::Small)
|
|
||||||
.buffer_font(cx)
|
|
||||||
.into_any_element()
|
|
||||||
};
|
|
||||||
|
|
||||||
parent.child(
|
parent.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.p_2()
|
.p_2()
|
||||||
.bg(colors.editor_background)
|
.bg(colors.editor_background)
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.child(
|
|
||||||
div()
|
|
||||||
.border_1()
|
|
||||||
.border_color(colors.border)
|
|
||||||
.p_2()
|
|
||||||
.bg(colors.editor_foreground.opacity(0.025))
|
|
||||||
.rounded_md()
|
|
||||||
.child(source_display),
|
|
||||||
)
|
|
||||||
.child(if stdout.is_empty() && error.is_none() {
|
.child(if stdout.is_empty() && error.is_none() {
|
||||||
Label::new("No output yet")
|
Label::new("No output yet")
|
||||||
.size(LabelSize::Small)
|
.size(LabelSize::Small)
|
||||||
|
|||||||
@@ -3,16 +3,6 @@
|
|||||||
-- Create a sandbox environment
|
-- Create a sandbox environment
|
||||||
local sandbox = {}
|
local sandbox = {}
|
||||||
|
|
||||||
-- For now, add all globals to `sandbox` (so there effectively is no sandbox).
|
|
||||||
-- We still need the logic below so that we can do things like overriding print() to write
|
|
||||||
-- to our in-memory log rather than to stdout, we will delete this loop (and re-enable
|
|
||||||
-- the I/O module being sandboxed below) to have things be sandboxed again.
|
|
||||||
for k, v in pairs(_G) do
|
|
||||||
if sandbox[k] == nil then
|
|
||||||
sandbox[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Allow access to standard libraries (safe subset)
|
-- Allow access to standard libraries (safe subset)
|
||||||
sandbox.string = string
|
sandbox.string = string
|
||||||
sandbox.table = table
|
sandbox.table = table
|
||||||
@@ -35,7 +25,8 @@ local io = {}
|
|||||||
io.open = sb_io_open
|
io.open = sb_io_open
|
||||||
|
|
||||||
-- Add the sandboxed io library to the sandbox environment
|
-- Add the sandboxed io library to the sandbox environment
|
||||||
-- sandbox.io = io -- Uncomment this line to re-enable sandboxed file I/O.
|
sandbox.io = io
|
||||||
|
|
||||||
|
|
||||||
-- Load the script with the sandbox environment
|
-- Load the script with the sandbox environment
|
||||||
local user_script_fn, err = load(user_script, nil, "t", sandbox)
|
local user_script_fn, err = load(user_script, nil, "t", sandbox)
|
||||||
|
|||||||
@@ -119,14 +119,6 @@ impl ScriptSession {
|
|||||||
let lua = Lua::new();
|
let lua = Lua::new();
|
||||||
lua.set_memory_limit(2 * 1024 * 1024 * 1024)?; // 2 GB
|
lua.set_memory_limit(2 * 1024 * 1024 * 1024)?; // 2 GB
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
|
|
||||||
// Use the project root dir as the script's current working dir.
|
|
||||||
if let Some(root_dir) = &root_dir {
|
|
||||||
if let Some(root_dir) = root_dir.to_str() {
|
|
||||||
globals.set("cwd", root_dir)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
globals.set(
|
globals.set(
|
||||||
"sb_print",
|
"sb_print",
|
||||||
lua.create_function({
|
lua.create_function({
|
||||||
|
|||||||
@@ -11639,7 +11639,7 @@ impl Editor {
|
|||||||
fn go_to_next_hunk(&mut self, _: &GoToHunk, window: &mut Window, cx: &mut Context<Self>) {
|
fn go_to_next_hunk(&mut self, _: &GoToHunk, window: &mut Window, cx: &mut Context<Self>) {
|
||||||
let snapshot = self.snapshot(window, cx);
|
let snapshot = self.snapshot(window, cx);
|
||||||
let selection = self.selections.newest::<Point>(cx);
|
let selection = self.selections.newest::<Point>(cx);
|
||||||
self.go_to_hunk_before_or_after_position(
|
self.go_to_hunk_after_or_before_position(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
selection.head(),
|
selection.head(),
|
||||||
Direction::Next,
|
Direction::Next,
|
||||||
@@ -11648,7 +11648,7 @@ impl Editor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn go_to_hunk_before_or_after_position(
|
fn go_to_hunk_after_or_before_position(
|
||||||
&mut self,
|
&mut self,
|
||||||
snapshot: &EditorSnapshot,
|
snapshot: &EditorSnapshot,
|
||||||
position: Point,
|
position: Point,
|
||||||
@@ -11699,7 +11699,7 @@ impl Editor {
|
|||||||
) {
|
) {
|
||||||
let snapshot = self.snapshot(window, cx);
|
let snapshot = self.snapshot(window, cx);
|
||||||
let selection = self.selections.newest::<Point>(cx);
|
let selection = self.selections.newest::<Point>(cx);
|
||||||
self.go_to_hunk_before_or_after_position(
|
self.go_to_hunk_after_or_before_position(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
selection.head(),
|
selection.head(),
|
||||||
Direction::Prev,
|
Direction::Prev,
|
||||||
@@ -13861,6 +13861,21 @@ impl Editor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let snapshot = self.snapshot(window, cx);
|
||||||
|
let newest_range = self.selections.newest::<Point>(cx).range();
|
||||||
|
|
||||||
|
let run_twice = snapshot
|
||||||
|
.hunks_for_ranges([newest_range])
|
||||||
|
.first()
|
||||||
|
.is_some_and(|hunk| {
|
||||||
|
let next_line = Point::new(hunk.row_range.end.0 + 1, 0);
|
||||||
|
self.hunk_after_position(&snapshot, next_line)
|
||||||
|
.is_some_and(|other| other.row_range == hunk.row_range)
|
||||||
|
});
|
||||||
|
|
||||||
|
if run_twice {
|
||||||
|
self.go_to_next_hunk(&GoToHunk, window, cx);
|
||||||
|
}
|
||||||
self.stage_or_unstage_diff_hunks(stage, ranges, cx);
|
self.stage_or_unstage_diff_hunks(stage, ranges, cx);
|
||||||
self.go_to_next_hunk(&GoToHunk, window, cx);
|
self.go_to_next_hunk(&GoToHunk, window, cx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9014,7 +9014,7 @@ fn diff_hunk_controls(
|
|||||||
let snapshot = editor.snapshot(window, cx);
|
let snapshot = editor.snapshot(window, cx);
|
||||||
let position =
|
let position =
|
||||||
hunk_range.end.to_point(&snapshot.buffer_snapshot);
|
hunk_range.end.to_point(&snapshot.buffer_snapshot);
|
||||||
editor.go_to_hunk_before_or_after_position(
|
editor.go_to_hunk_after_or_before_position(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
position,
|
position,
|
||||||
Direction::Next,
|
Direction::Next,
|
||||||
@@ -9050,7 +9050,7 @@ fn diff_hunk_controls(
|
|||||||
let snapshot = editor.snapshot(window, cx);
|
let snapshot = editor.snapshot(window, cx);
|
||||||
let point =
|
let point =
|
||||||
hunk_range.start.to_point(&snapshot.buffer_snapshot);
|
hunk_range.start.to_point(&snapshot.buffer_snapshot);
|
||||||
editor.go_to_hunk_before_or_after_position(
|
editor.go_to_hunk_after_or_before_position(
|
||||||
&snapshot,
|
&snapshot,
|
||||||
point,
|
point,
|
||||||
Direction::Prev,
|
Direction::Prev,
|
||||||
|
|||||||
@@ -152,10 +152,7 @@ impl GoToLine {
|
|||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
match event {
|
match event {
|
||||||
editor::EditorEvent::Blurred => {
|
editor::EditorEvent::Blurred => cx.emit(DismissEvent),
|
||||||
self.prev_scroll_position.take();
|
|
||||||
cx.emit(DismissEvent)
|
|
||||||
}
|
|
||||||
editor::EditorEvent::BufferEdited { .. } => self.highlight_current_line(cx),
|
editor::EditorEvent::BufferEdited { .. } => self.highlight_current_line(cx),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,6 @@
|
|||||||
- [Rust](./languages/rust.md)
|
- [Rust](./languages/rust.md)
|
||||||
- [Scala](./languages/scala.md)
|
- [Scala](./languages/scala.md)
|
||||||
- [Scheme](./languages/scheme.md)
|
- [Scheme](./languages/scheme.md)
|
||||||
- [Shell Script](./languages/sh.md)
|
|
||||||
- [Svelte](./languages/svelte.md)
|
- [Svelte](./languages/svelte.md)
|
||||||
- [Swift](./languages/swift.md)
|
- [Swift](./languages/swift.md)
|
||||||
- [Tailwind CSS](./languages/tailwindcss.md)
|
- [Tailwind CSS](./languages/tailwindcss.md)
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ Zed supports hundreds of programming languages and text formats. Some work out-o
|
|||||||
- [Go](./languages/go.md)
|
- [Go](./languages/go.md)
|
||||||
- [Groovy](./languages/groovy.md)
|
- [Groovy](./languages/groovy.md)
|
||||||
- [Haskell](./languages/haskell.md)
|
- [Haskell](./languages/haskell.md)
|
||||||
- [Helm](./languages/helm.md)
|
|
||||||
- [HTML](./languages/html.md)
|
- [HTML](./languages/html.md)
|
||||||
- [Java](./languages/java.md)
|
- [Java](./languages/java.md)
|
||||||
- [JavaScript](./languages/javascript.md)
|
- [JavaScript](./languages/javascript.md)
|
||||||
@@ -59,7 +58,7 @@ Zed supports hundreds of programming languages and text formats. Some work out-o
|
|||||||
- [Shell Script](./languages/sh.md)
|
- [Shell Script](./languages/sh.md)
|
||||||
- [Svelte](./languages/svelte.md)
|
- [Svelte](./languages/svelte.md)
|
||||||
- [Swift](./languages/swift.md)
|
- [Swift](./languages/swift.md)
|
||||||
- [Tailwind CSS](./languages/tailwindcss.md)
|
- [TailwindCSS](./languages/tailwindcss.md)
|
||||||
- [Terraform](./languages/terraform.md)
|
- [Terraform](./languages/terraform.md)
|
||||||
- [TOML](./languages/toml.md)
|
- [TOML](./languages/toml.md)
|
||||||
- [TypeScript](./languages/typescript.md)
|
- [TypeScript](./languages/typescript.md)
|
||||||
|
|||||||
Reference in New Issue
Block a user