Undo traced point to last point when we click ctrl+z while tracing/drawing annotation and not the entire tracing

PDF.js Express Version
Version: 7.2.0

Detailed description of issue
Suppose if user accidently put one vertex at wrong place while tracing area/perimeter. So if he hits CTRL+Z to undo that last vertex point while tracing then it should get removed/undo and not the entire annotation. Also tracing should not get ended if undo is triggered.

How can I achieve this ?

Expected behaviour
Undo a vertex point while tracing if user accidently put one vertex at wrong place then by clicking ctrl+z it should go back to point 1 back.

Code snippet
this.viewerInstance.hotkeys.on('ctrl+z, command+z', e => {
e.preventDefault();
this.undoRedoEnable.emit(new UndoRedoEnable(!this.getHistoryManager().canUndo(),this.isRedo)); });

Hey!

This code should do the trick for you. Basically you just need to get the annotation thats being drawn and pop an item of its path.

I also had to do a hack to work around the history manager deleting the last annotation.

  instance.hotkeys.on(
    instance.hotkeys.Keys.CTRL_Z,
    (e) => {
      const currentTool = instance.getToolMode();
      if (currentTool.name === instance.Tools.ToolNames.PERIMETER_MEASUREMENT) {

        const historyManager = instance.docViewer.getAnnotationHistoryManager();

        historyManager.one('historyChanged', () => {
          historyManager.redo();
        })

        e.preventDefault();
        e.stopPropagation();
        if (currentTool.annotation && currentTool.annotation.popPath) {
          currentTool.annotation.popPath();
        }
      }
    }
  )

Thanks!
Logan