avoid output showing up in kill ring (via TextArea.setText, JEditBuffer.remove, UndoManager.contentRemoved), e.g. relevant for action "paste-deleted";
authorwenzelm
Tue, 01 May 2018 16:42:14 +0200
changeset 68060 3931ed905e93
parent 68059 6f7829c14f5a
child 68061 81d90f830f99
child 68062 ee88c0fccbae
avoid output showing up in kill ring (via TextArea.setText, JEditBuffer.remove, UndoManager.contentRemoved), e.g. relevant for action "paste-deleted";
src/Tools/jEdit/src/jedit_lib.scala
src/Tools/jEdit/src/pretty_text_area.scala
--- a/src/Tools/jEdit/src/jedit_lib.scala	Mon Apr 30 22:13:21 2018 +0100
+++ b/src/Tools/jEdit/src/jedit_lib.scala	Tue May 01 16:42:14 2018 +0200
@@ -129,6 +129,13 @@
 
   def buffer_file(buffer: Buffer): Option[JFile] = check_file(buffer_name(buffer))
 
+  def buffer_undo_in_progress[A](buffer: JEditBuffer, body: => A): A =
+  {
+    val undo_in_progress = buffer.isUndoInProgress
+    def set(b: Boolean) { Untyped.set[Boolean](buffer, "undoInProgress", b) }
+    try { set(true); body } finally { set(undo_in_progress) }
+  }
+
 
   /* main jEdit components */
 
--- a/src/Tools/jEdit/src/pretty_text_area.scala	Mon Apr 30 22:13:21 2018 +0100
+++ b/src/Tools/jEdit/src/pretty_text_area.scala	Tue May 01 16:42:14 2018 +0200
@@ -144,7 +144,7 @@
             JEdit_Lib.buffer_edit(getBuffer) {
               rich_text_area.active_reset()
               getBuffer.setFoldHandler(new Fold_Handling.Document_Fold_Handler(rendering))
-              setText(text)
+              JEdit_Lib.buffer_undo_in_progress(getBuffer, setText(text))
               setCaretPosition(0)
             }
           }