T17 Editor: CodeEditor with gutter, folds, minimap, rulers, guides, brackets, whitespace, cursors, multi-cursor, sticky scroll, inlay hints, lenses, decorations, ghost text, inline chat and diff (T17a); completions, signatures, hover, code actions, rename, references, outline, go to symbol, call and type hierarchy (T17b); find and replace, search panel and filters (T17c); problems, output, debug console, extensions, settings with JSON, keybindings, theme previews, welcome, recent projects, switcher, task runner (T17d); status items (T17e)

Shared: generic undo History, OverflowMenu icon and tooltip, StatusBarItem leading, six Lucide icons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-09-26 00:43:41 -04:00
1 parent c229a096ca
commit d05754ac19
59 files changed
+10820 -71

No files matched your search

+19 -10
View File
@@ -93,17 +93,26 @@ pub(crate) struct Snapshot {
/// Typing within this pause joins one undo step.
const JOIN: Duration = Duration::from_millis(900);
/// Undo and redo as whole-text snapshots.
#[derive(Default)]
pub(crate) struct History {
undo: Vec<Snapshot>,
redo: Vec<Snapshot>,
/// Undo and redo as whole snapshots of what an editor holds.
pub(crate) struct History<S> {
undo: Vec<S>,
redo: Vec<S>,
typing_since: Option<Instant>,
}
impl History {
impl<S> Default for History<S> {
fn default() -> Self {
Self {
undo: Vec::new(),
redo: Vec::new(),
typing_since: None,
}
}
}
impl<S> History<S> {
/// Records the state before an edit. Typing in one burst makes one step.
pub fn record(&mut self, before: Snapshot, typing: bool) {
pub fn record(&mut self, before: S, typing: bool) {
let joins = typing && self.typing_since.is_some_and(|at| at.elapsed() < JOIN);
if !joins {
self.undo.push(before);
@@ -112,14 +121,14 @@ impl History {
self.redo.clear();
}
pub fn undo(&mut self, current: Snapshot) -> Option<Snapshot> {
pub fn undo(&mut self, current: S) -> Option<S> {
let previous = self.undo.pop()?;
self.redo.push(current);
self.typing_since = None;
Some(previous)
}
pub fn redo(&mut self, current: Snapshot) -> Option<Snapshot> {
pub fn redo(&mut self, current: S) -> Option<S> {
let next = self.redo.pop()?;
self.undo.push(current);
self.typing_since = None;
@@ -175,7 +184,7 @@ mod tests {
text: text.into(),
selection: text.len()..text.len(),
};
let mut history = History::default();
let mut history = History::<Snapshot>::default();
history.record(snap(""), true);
history.record(snap("a"), true);
history.record(snap("ab"), false);
+3 -2
View File
@@ -11,7 +11,8 @@ use gpui::{
};
pub(crate) use actions::{Backspace, Down, Enter, Submit, Up, bind_keys};
use edit::{History, Snapshot};
use edit::Snapshot;
pub(crate) use edit::{History, from_utf16, to_utf16};
use crate::theme::ActiveTheme;
@@ -64,7 +65,7 @@ pub struct TextInput {
max_len: Option<usize>,
highlighter: Option<Highlighter>,
disabled: bool,
history: History,
history: History<Snapshot>,
pub(crate) layout: Option<Layout>,
pub(crate) scroll: Point<Pixels>,
selecting: bool,