Skip to content

Commit 9ef01e2

Browse files
unhappychoiceclaude
andcommitted
feat: skip cursor movement to indentation
When adding new lines, start typing at the indentation level instead of moving the cursor from column 0. This speeds up playback for deeply indented code and focuses on content changes rather than formatting. - Insert lines with indentation pre-filled - Position cursor at indentation end immediately - Type only the actual content characters 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f3d7672 commit 9ef01e2

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/animation.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,21 @@ impl AnimationEngine {
668668
// (the next line moves up to this position)
669669
}
670670
LineChangeType::Addition => {
671-
// Insert empty line at current buffer position
671+
let content = &line_change.content;
672+
let indentation_len = content.chars().take_while(|c| c.is_whitespace()).count();
673+
674+
// Insert line with indentation already included
675+
let indentation: String = content.chars().take(indentation_len).collect();
672676
self.steps.push(AnimationStep::InsertLine {
673677
line: buffer_line,
674-
content: String::new(),
678+
content: indentation,
675679
});
676680

677-
// Type each character
678-
for (col, ch) in line_change.content.chars().enumerate() {
681+
// Type each character after the indentation
682+
for (i, ch) in content.chars().skip(indentation_len).enumerate() {
679683
self.steps.push(AnimationStep::InsertChar {
680684
line: buffer_line,
681-
col,
685+
col: indentation_len + i,
682686
ch,
683687
});
684688
}
@@ -822,9 +826,10 @@ impl AnimationEngine {
822826
}
823827
AnimationStep::InsertLine { line, content } => {
824828
self.active_pane = ActivePane::Editor;
829+
let content_len = content.chars().count();
825830
self.buffer.insert_line(line, content);
826831
self.buffer.cursor_line = line;
827-
self.buffer.cursor_col = 0;
832+
self.buffer.cursor_col = content_len;
828833

829834
// Track line offset for old_highlights mapping
830835
self.line_offset += 1;

0 commit comments

Comments
 (0)