简体   繁体   English

如何暂停Avalonedit的Undostack?

[英]How to Suspend the Undostack of Avalonedit?

  • I perform a massive text-change on the editor 我在编辑器上执行了大量的文本更改
  • i can not (or very difficult) determine when the changes begin end (the textchange is released by scrolling) 我不能(或非常难)确定更改何时开始结束(通过滚动释放文本更改)
  • i dont want to be able to undo the changes 我不希望能够撤消更改

for this reasons i want to suspend the listening of the stack (or do a pop after any textchange). 由于这个原因,我想暂停监听堆栈(或在任何textchange之后执行pop)。 but

  • the stack offers no method to pop a stackelement without performing the undo 堆栈没有提供弹出stackelement而不执行undo的方法
  • i dont want to clear the stack completly 我不想完全清除堆栈
  • there´s no method to detach the stack from the textdocument 没有方法从文本文档中分离堆栈
  • there´s no method to suspend the listening 没有办法暂停收听

do you know a possibility to solve this? 你知道解决这个问题的可能性吗?

You want the undo stack to not record some changes, but don't want to be cleared it either? 您希望撤消堆栈不记录某些更改,但是也不想将其清除? That would mean the contents of the undo stack might be inconsistent with the document content - when the user then presses undo, it might end up crashing or changing text other than in the expected location. 这意味着撤消堆栈的内容可能与文档内容不一致 - 当用户然后按下撤消时,它可能最终崩溃或更改除预期位置之外的文本。

For this reason, AvalonEdit does not support this operation. 因此,AvalonEdit不支持此操作。 We try very hard to avoid inconsistent undo stacks - for example, re-entrant updates (changing the document within a TextDocument.Changed event handler) are disallowed. 我们非常努力地避免不一致的撤销堆栈 - 例如,不允许重入更新(在TextDocument.Changed事件处理程序中更改文档)。

The closest you can get to disabling the undo stack is to set 您可以设置的最接近禁用撤消堆栈的方法是设置

document.UndoStack.SizeLimit = 0;

This will effectively disable listening for changes, but it'll also clear the undo stack. 这将有效地禁用侦听更改,但它也将清除撤消堆栈。

As a side note: it is possible to 'detach' an undo stack (by setting document.UndoStack to another undo stack), but that will also clear the old undo stack. 作为旁注:可以“分离”撤销堆栈(通过将document.UndoStack设置为另一个撤消堆栈),但这也将清除旧的撤消堆栈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM