Skip to content

Commit

Permalink
Add undo logging
Browse files Browse the repository at this point in the history
  • Loading branch information
1whatleytay committed Nov 16, 2024
1 parent 67d8a95 commit 1c5571f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,17 @@ export class Editor {

// Returns the "reverse" step.
apply(frame: Frame): Frame {
const from = this.data.length

const deleted = this.data.splice(
frame.index,
frame.replaced,
...frame.deleted
)

invoke('send_trace', { text: `UNDO line lengths ${from} to ${this.data.length}` })
.then(() => {})

this.onDirty(frame.index, frame.replaced, frame.deleted)

return {
Expand All @@ -225,6 +231,9 @@ export class Editor {

const frame = step.frame

invoke('send_trace', { text: `UNDO ${JSON.stringify(step)}` })
.then(() => {})

const reverse = this.apply(frame)

reverseQueue.push({
Expand Down

0 comments on commit 1c5571f

Please sign in to comment.