Skip to content

Commit

Permalink
don't create undo point when no changes have been made
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcoles committed Jul 16, 2024
1 parent c621fd3 commit 2bcff60
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rebuild.e
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,8 @@ ENDPROC

PROC addUndo()
DEF strStream:PTR TO stringStreamer
DEF prevStream:PTR TO stringStreamer
DEF doAdd=FALSE,i
WHILE undoPos<(undoData.count()-1)
strStream:=undoData.item(undoData.count()-1)
END strStream
Expand All @@ -2946,8 +2948,20 @@ PROC addUndo()

NEW strStream.create()
saveStream(strStream)
undoData.add(strStream)
undoPos++

IF (undoData.count()=0)
doAdd:=TRUE
ELSE
prevStream:=undoData.item(undoData.count()-1)
IF prevStream.compareTo(strStream)=FALSE THEN doAdd:=TRUE
ENDIF

IF doAdd
undoData.add(strStream)
undoPos++
ELSE
END strStream
ENDIF

menuDisable(win,MENU_EDIT,MENU_EDIT_UNDO,0,undoPos=0)
menuDisable(win,MENU_EDIT,MENU_EDIT_REDO,0,undoPos>=(undoData.count()-1))
Expand Down
13 changes: 13 additions & 0 deletions stringStreamer.e
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,16 @@ PROC reset() OF stringStreamer
self.currpos:=0
ENDPROC

PROC compareTo(otherStream:PTR TO stringStreamer) OF stringStreamer
DEF i

IF otherStream.data.count()<>self.data.count()
RETURN FALSE
ELSE
i:=otherStream.data.count()-1
WHILE (i>=0)
IF StrCmp(otherStream.data.item(i),self.data.item(i))=FALSE THEN RETURN FALSE
i--
ENDWHILE
ENDIF
ENDPROC TRUE

0 comments on commit 2bcff60

Please sign in to comment.