Skip to content

Commit

Permalink
Fix a subtle bug with the mark API
Browse files Browse the repository at this point in the history
When I refactored the undo code, I changed (perhaps wrongly) the
semantics of Undo marking. Adjust the filesystem interface to work
correctly despite this.

This is a better fix for #499.
  • Loading branch information
rjkroege committed Jul 9, 2024
1 parent bae1065 commit ae09163
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion file/observable_editable_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ func (e *ObservableEditableBuffer) notifyTagObservers(before TagStatus) {

// Mark is a forwarding function for file.Mark.
// This sets an undo point. NB: call Mark before mutating the file.
// seq must be 1 to enable Undo/Redo on the file.
// Argument seq should be > 0 to create a valid Undo/Redo point.
func (e *ObservableEditableBuffer) Mark(seq int) {
log.Println("oeb.Mark(), before:", e.DebugSeqState(), "newseq:", seq)

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, windows-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, windows-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, windows-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, windows-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, macos-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, windows-latest)

undefined: log

Check failure on line 196 in file/observable_editable_buffer.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, windows-latest)

undefined: log
e.f.Mark()
e.seq = seq
}
Expand Down Expand Up @@ -529,3 +530,8 @@ func (e *ObservableEditableBuffer) End() OffsetTuple {
func (e *ObservableEditableBuffer) MakeBufferCursor(p0, p1 OffsetTuple) *BufferCursor {
return MakeBufferCursor(e.f, p0, p1)
}

// DebugSeqState returns the seq state for debugging purposes.
func (e *ObservableEditableBuffer) DebugSeqState() string {
return fmt.Sprintf("oeb seq %d putseq %d treatasclean %v", e.seq, e.putseq, e.treatasclean)
}
5 changes: 3 additions & 2 deletions xfid.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,9 @@ forloop:
case "nomark": // turn off automatic marking
w.nomark = true
case "mark": // mark file
global.seq++
w.body.file.Mark(global.seq)
w.nomark = false
// global.seq++
// w.body.file.Mark(global.seq)
case "nomenu": // turn off automatic menu
w.filemenu = false
case "menu": // enable automatic menu
Expand Down

0 comments on commit ae09163

Please sign in to comment.