View | Details | Raw Unified | Return to bug 199699
Collapse All | Expand All

(-)a/openide.text/src/org/openide/text/UndoRedoManager.java (-14 / +28 lines)
Lines 105-111 Link Here
105
     * <br/>
105
     * <br/>
106
     * Next performed edit will set afterSaveEdit field.
106
     * Next performed edit will set afterSaveEdit field.
107
     */
107
     */
108
    static final UndoableEdit SAVEPOINT = new CompoundEdit();
108
    static final UndoableEdit SAVEPOINT = new SpecialEdit();
109
109
110
    /**
110
    /**
111
     * Start a group of edits which will be committed as a single edit
111
     * Start a group of edits which will be committed as a single edit
Lines 116-141 Link Here
116
     * While coalescing edits, any undo/redo/save implicitly delimits
116
     * While coalescing edits, any undo/redo/save implicitly delimits
117
     * a commit-group.
117
     * a commit-group.
118
     */
118
     */
119
    static final UndoableEdit BEGIN_COMMIT_GROUP = new CompoundEdit();
119
    static final UndoableEdit BEGIN_COMMIT_GROUP = new SpecialEdit();
120
120
121
    /** End a group of edits. */
121
    /** End a group of edits. */
122
    static final UndoableEdit END_COMMIT_GROUP = new CompoundEdit();
122
    static final UndoableEdit END_COMMIT_GROUP = new SpecialEdit();
123
    
123
    
124
    /**
124
    /**
125
     * Any coalesced edits become a commit-group and a new commit-group
125
     * Any coalesced edits become a commit-group and a new commit-group
126
     * is started.
126
     * is started.
127
     */
127
     */
128
    static final UndoableEdit MARK_COMMIT_GROUP = new CompoundEdit();
128
    static final UndoableEdit MARK_COMMIT_GROUP = new SpecialEdit();
129
    
130
    static {
131
        // Prevent the special edits to merge with any other edits.
132
        // This might happen in an errorneous situation when e.g. two undo managers
133
        // are attached to the same document at once.
134
        ((CompoundEdit)SAVEPOINT).end();
135
        ((CompoundEdit)BEGIN_COMMIT_GROUP).end();
136
        ((CompoundEdit)END_COMMIT_GROUP).end();
137
        ((CompoundEdit)MARK_COMMIT_GROUP).end();
138
    }
139
129
140
130
141
    CloneableEditorSupport support;
131
    CloneableEditorSupport support;
Lines 687-690 Link Here
687
        }
677
        }
688
    }
678
    }
689
679
680
    private static class SpecialEdit extends CompoundEdit {
681
682
        public SpecialEdit()
683
        {
684
            super();
685
            // Prevent the special edits to merge with any other edits.
686
            // This might happen in an errorneous situation when
687
            // e.g. two undo managers are attached to the same document at once.
688
            end();
689
        }
690
691
        @Override
692
        public boolean canRedo()
693
        {
694
            return true;
695
        }
696
697
        @Override
698
        public boolean canUndo()
699
        {
700
            return true;
701
        }
702
    }
703
690
}
704
}

Return to bug 199699