This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

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

(-)a/editor.actions/src/org/netbeans/modules/editor/actions/AddCaretAction.java (-1 / +1 lines)
Lines 115-121 Link Here
115
                            }
115
                            }
116
                        });
116
                        });
117
117
118
                        editorCaret.addCarets(dots);
118
                        editorCaret.addCarets(dots, null); // TODO handle biases
119
                    }
119
                    }
120
                });
120
                });
121
            }
121
            }
(-)a/editor.lib2/apichanges.xml (+15 lines)
Lines 107-112 Link Here
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
        <change id="EditorCaret-bias">
111
            <summary>Position.Bias support added to EditorCaret</summary>
112
            <version major="2" minor="12"/>
113
            <date day="2" month="5" year="2016"/>
114
            <author login="mmetelka"/>
115
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes" deprecation="no" deletion="no" modification="no" />
116
            <description>
117
                <p>
118
                    CaretInfo.getDotBias() and CaretInfo.getMarkBias() added together
119
                    with other methods and parameters for bias manipulation to properly handle bidirectional text.
120
                </p>
121
            </description>
122
            <class name="EditorCaret" package="org.netbeans.api.editor.caret"/>
123
            <issue number="259023"/>
124
        </change>
110
        <change id="EditorUtilities.addCaretUndoableEdit">
125
        <change id="EditorUtilities.addCaretUndoableEdit">
111
            <summary>EditorUtilities.addCaretUndoableEdit added</summary>
126
            <summary>EditorUtilities.addCaretUndoableEdit added</summary>
112
            <version major="2" minor="11"/>
127
            <version major="2" minor="11"/>
(-)a/editor.lib2/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.editor.lib2/1
2
OpenIDE-Module: org.netbeans.modules.editor.lib2/1
3
OpenIDE-Module-Implementation-Version: 47
3
OpenIDE-Module-Implementation-Version: 48
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml
6
OpenIDE-Module-Needs: org.netbeans.modules.editor.actions
6
OpenIDE-Module-Needs: org.netbeans.modules.editor.actions
(-)a/editor.lib2/nbproject/project.properties (-1 / +1 lines)
Lines 43-49 Link Here
43
is.autoload=true
43
is.autoload=true
44
javac.source=1.7
44
javac.source=1.7
45
javac.compilerargs=-Xlint:unchecked
45
javac.compilerargs=-Xlint:unchecked
46
spec.version.base=2.11.0
46
spec.version.base=2.12.0
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/editor.lib2/src/org/netbeans/api/editor/caret/CaretInfo.java (+35 lines)
Lines 45-50 Link Here
45
import java.util.logging.Logger;
45
import java.util.logging.Logger;
46
import javax.swing.text.Position;
46
import javax.swing.text.Position;
47
import org.netbeans.api.annotations.common.CheckForNull;
47
import org.netbeans.api.annotations.common.CheckForNull;
48
import org.netbeans.api.annotations.common.NonNull;
48
49
49
/**
50
/**
50
 * Immutable info about a single caret used in caret API - see {@link EditorCaret}.
51
 * Immutable info about a single caret used in caret API - see {@link EditorCaret}.
Lines 67-81 Link Here
67
    private final CaretItem caretItem;
68
    private final CaretItem caretItem;
68
69
69
    private final Position dotPos;
70
    private final Position dotPos;
71
    
72
    private final Position.Bias dotBias;
70
73
71
    private final Position markPos;
74
    private final Position markPos;
75
    
76
    private final Position.Bias markBias;
72
77
73
    private final Point magicCaretPosition;
78
    private final Point magicCaretPosition;
74
79
75
    CaretInfo(CaretItem caretItem) {
80
    CaretInfo(CaretItem caretItem) {
76
        this.caretItem = caretItem;
81
        this.caretItem = caretItem;
77
        this.dotPos = caretItem.getDotPosition();
82
        this.dotPos = caretItem.getDotPosition();
83
        this.dotBias = caretItem.getDotBias();
78
        this.markPos = caretItem.getMarkPosition();
84
        this.markPos = caretItem.getMarkPosition();
85
        this.markBias = caretItem.getMarkBias();
79
        this.magicCaretPosition = caretItem.getMagicCaretPosition();
86
        this.magicCaretPosition = caretItem.getMagicCaretPosition();
80
    }
87
    }
81
88
Lines 90-95 Link Here
90
    }
97
    }
91
98
92
    /**
99
    /**
100
     * Get a bias of the dot position which is either
101
     * {@link Position.Bias.Forward} or {@link Position.Bias.Backward} depending
102
     * on whether the caret biases towards the next character or previous one.
103
     * The bias is always forward for non bidirectional text.
104
     *
105
     * @return either forward or backward bias.
106
     * @since 2.12
107
     */
108
    @NonNull
109
    public Position.Bias getDotBias() {
110
        return dotBias;
111
    }
112
113
    /**
93
     * Return either the same object like {@link #getDotPosition()} if there's no selection
114
     * Return either the same object like {@link #getDotPosition()} if there's no selection
94
     * or return position denoting the other end of an existing selection (which is either before
115
     * or return position denoting the other end of an existing selection (which is either before
95
     * or after the dot position depending of how the selection was created).
116
     * or after the dot position depending of how the selection was created).
Lines 102-107 Link Here
102
    }
123
    }
103
    
124
    
104
    /**
125
    /**
126
     * Get a bias of the mark position which is either
127
     * {@link Position.Bias.Forward} or {@link Position.Bias.Backward} depending
128
     * on whether the caret biases towards the next character or previous one.
129
     * The bias is always forward for non bidirectional text.
130
     *
131
     * @return either forward or backward bias.
132
     * @since 2.12
133
     */
134
    @NonNull
135
    public Position.Bias getMarkBias() {
136
        return markBias;
137
    }
138
139
    /**
105
     * Fetches the current position of the caret.
140
     * Fetches the current position of the caret.
106
     *
141
     *
107
     * @return the position &gt;=0
142
     * @return the position &gt;=0
(-)a/editor.lib2/src/org/netbeans/api/editor/caret/CaretItem.java (-1 / +28 lines)
Lines 47-52 Link Here
47
import javax.swing.text.JTextComponent;
47
import javax.swing.text.JTextComponent;
48
import javax.swing.text.Position;
48
import javax.swing.text.Position;
49
import org.netbeans.api.annotations.common.CheckForNull;
49
import org.netbeans.api.annotations.common.CheckForNull;
50
import org.netbeans.api.annotations.common.NonNull;
50
51
51
/**
52
/**
52
 * A single caret inside {@link EditorCaret} handled internally by EditorCaret.
53
 * A single caret inside {@link EditorCaret} handled internally by EditorCaret.
Lines 75-82 Link Here
75
    
76
    
76
    private Position dotPos;
77
    private Position dotPos;
77
78
79
    private Position.Bias dotBias;
80
78
    private Position markPos;
81
    private Position markPos;
79
82
83
    private Position.Bias markBias;
84
80
    private Point magicCaretPosition;
85
    private Point magicCaretPosition;
81
    
86
    
82
    /**
87
    /**
Lines 96-105 Link Here
96
     */
101
     */
97
    private int statusBits;
102
    private int statusBits;
98
103
99
    CaretItem(EditorCaret editorCaret, Position dotPos, Position markPos) {
104
    CaretItem(EditorCaret editorCaret, Position dotPos, Position.Bias dotBias, Position markPos, Position.Bias markBias) {
100
        this.editorCaret = editorCaret;
105
        this.editorCaret = editorCaret;
101
        this.dotPos = dotPos;
106
        this.dotPos = dotPos;
107
        this.dotBias = dotBias;
102
        this.markPos = markPos;
108
        this.markPos = markPos;
109
        this.markBias = markBias;
103
        this.statusBits = UPDATE_CARET_BOUNDS; // Request visual bounds updating automatically
110
        this.statusBits = UPDATE_CARET_BOUNDS; // Request visual bounds updating automatically
104
    }
111
    }
105
    
112
    
Lines 146-151 Link Here
146
    Position getDotPosition() {
153
    Position getDotPosition() {
147
        return dotPos;
154
        return dotPos;
148
    }
155
    }
156
    
157
    /**
158
     * Get the bias of the dot either forward or backward bias.
159
     *
160
     * @return either forward or backward bias.
161
     */
162
    @NonNull
163
    Position.Bias getDotBias() {
164
        return dotBias;
165
    }
149
166
150
    /**
167
    /**
151
     * Return either the same object like {@link #getDotPosition()} if there's
168
     * Return either the same object like {@link #getDotPosition()} if there's
Lines 161-166 Link Here
161
        return markPos;
178
        return markPos;
162
    }
179
    }
163
180
181
    /**
182
     * Get the bias of the mark either forward or backward bias.
183
     *
184
     * @return either forward or backward bias.
185
     */
186
    @NonNull
187
    Position.Bias getMarkBias() {
188
        return markBias;
189
    }
190
164
    int getDot() {
191
    int getDot() {
165
        return (dotPos != null) ? dotPos.getOffset() : 0;
192
        return (dotPos != null) ? dotPos.getOffset() : 0;
166
    }
193
    }
(-)a/editor.lib2/src/org/netbeans/api/editor/caret/CaretTransaction.java (-2 / +8 lines)
Lines 562-568 Link Here
562
        }
562
        }
563
    }
563
    }
564
564
565
    static CaretItem[] asCaretItems(EditorCaret caret, @NonNull List<Position> dotAndSelectionStartPosPairs) {
565
    static CaretItem[] asCaretItems(EditorCaret caret, @NonNull List<Position> dotAndSelectionStartPosPairs,
566
            List<Position.Bias> dotAndMarkBiases)
567
    {
566
        int size = dotAndSelectionStartPosPairs.size();
568
        int size = dotAndSelectionStartPosPairs.size();
567
        if ((size & 1) != 0) {
569
        if ((size & 1) != 0) {
568
            throw new IllegalStateException("Passed list has size=" + size + " which is not an even number.");
570
            throw new IllegalStateException("Passed list has size=" + size + " which is not an even number.");
Lines 570-578 Link Here
570
        CaretItem[] addedCarets = new CaretItem[size >> 1];
572
        CaretItem[] addedCarets = new CaretItem[size >> 1];
571
        int listIndex = 0;
573
        int listIndex = 0;
572
        for (int j = 0; j < addedCarets.length; j++) {
574
        for (int j = 0; j < addedCarets.length; j++) {
575
            Position.Bias dotBias = (dotAndMarkBiases != null) ? dotAndMarkBiases.get(listIndex) : Position.Bias.Forward;
573
            Position dotPos = dotAndSelectionStartPosPairs.get(listIndex++);
576
            Position dotPos = dotAndSelectionStartPosPairs.get(listIndex++);
577
578
            Position.Bias markBias = (dotAndMarkBiases != null) ? dotAndMarkBiases.get(listIndex) : Position.Bias.Forward;
574
            Position selectionStartPos = dotAndSelectionStartPosPairs.get(listIndex++);
579
            Position selectionStartPos = dotAndSelectionStartPosPairs.get(listIndex++);
575
            CaretItem caretItem = new CaretItem(caret, dotPos, selectionStartPos);
580
581
            CaretItem caretItem = new CaretItem(caret, dotPos, dotBias, selectionStartPos, markBias);
576
            addedCarets[j] = caretItem;
582
            addedCarets[j] = caretItem;
577
        }
583
        }
578
        return addedCarets;
584
        return addedCarets;
(-)a/editor.lib2/src/org/netbeans/api/editor/caret/EditorCaret.java (-15 / +64 lines)
Lines 401-407 Link Here
401
    public EditorCaret() {
401
    public EditorCaret() {
402
        caretItems = new GapList<>();
402
        caretItems = new GapList<>();
403
        sortedCaretItems = new GapList<>();
403
        sortedCaretItems = new GapList<>();
404
        CaretItem singleCaret = new CaretItem(this, null, null);
404
        CaretItem singleCaret = new CaretItem(this, null, Position.Bias.Forward, null, Position.Bias.Forward);
405
        caretItems.add(singleCaret);
405
        caretItems.add(singleCaret);
406
        sortedCaretItems.add(singleCaret);
406
        sortedCaretItems.add(singleCaret);
407
407
Lines 418-423 Link Here
418
    public int getDot() {
418
    public int getDot() {
419
        return getLastCaret().getDot();
419
        return getLastCaret().getDot();
420
    }
420
    }
421
    
422
    /**
423
     * Get a bias of the dot position which is either
424
     * {@link Position.Bias.Forward} or {@link Position.Bias.Backward} depending
425
     * on whether the caret biases towards the next character or previous one.
426
     * The bias is always forward for non bidirectional text document.
427
     *
428
     * @return either forward or backward bias.
429
     * @since 2.12
430
     */
431
    @NonNull
432
    public Position.Bias getDotBias() {
433
        return getLastCaret().getDotBias();
434
    }
421
435
422
    /**
436
    /**
423
     * Get mark offset of the last created caret in the underlying document.
437
     * Get mark offset of the last created caret in the underlying document.
Lines 431-436 Link Here
431
    }
445
    }
432
    
446
    
433
    /**
447
    /**
448
     * Get a bias of the mark position which is either
449
     * {@link Position.Bias.Forward} or {@link Position.Bias.Backward} depending
450
     * on whether the caret biases towards the next character or previous one.
451
     * The bias is always forward for non bidirectional text document.
452
     *
453
     * @return either forward or backward bias.
454
     * @since 2.12
455
     */
456
    @NonNull
457
    public Position.Bias getMarkBias() {
458
        return getLastCaret().getMarkBias();
459
    }
460
461
    /**
434
     * Get information about all existing carets in the order they were created.
462
     * Get information about all existing carets in the order they were created.
435
     * <br>
463
     * <br>
436
     * The list always has at least one item. The last caret (last item of the list)
464
     * The list always has at least one item. The last caret (last item of the list)
Lines 530-536 Link Here
530
     * @see Caret#setDot(int) 
558
     * @see Caret#setDot(int) 
531
     */
559
     */
532
    public @Override void setDot(final int offset) {
560
    public @Override void setDot(final int offset) {
533
        setDot(offset, MoveCaretsOrigin.DEFAULT);
561
        setDot(offset, Position.Bias.Forward, MoveCaretsOrigin.DEFAULT);
534
    }
562
    }
535
563
536
    /**
564
    /**
Lines 547-557 Link Here
547
     * actions (pg up, pg down, left, right, ...).
575
     * actions (pg up, pg down, left, right, ...).
548
     * </p>
576
     * </p>
549
     * @param offset new offset for the caret
577
     * @param offset new offset for the caret
578
     * @param bias new bias for the caret. Use either {@link Position.Bias.Forward}
579
     *  or {@link Position.Bias.Backward} depending on whether the caret should bias
580
     *  towards the next character or previous one. Use forward bias for non-bidirectional text document.
550
     * @param orig specifies the operation which caused the caret to move.
581
     * @param orig specifies the operation which caused the caret to move.
551
     * @see #setDot(int) 
582
     * @see #setDot(int) 
552
     * @since 2.10
583
     * @since 2.10
553
     */
584
     */
554
    public void setDot(final int offset, MoveCaretsOrigin orig) {
585
    public void setDot(final int offset, Position.Bias bias, MoveCaretsOrigin orig) {
555
        if (LOG.isLoggable(Level.FINE)) {
586
        if (LOG.isLoggable(Level.FINE)) {
556
            LOG.fine("setDot: offset=" + offset); //NOI18N
587
            LOG.fine("setDot: offset=" + offset); //NOI18N
557
            if (LOG.isLoggable(Level.FINEST)) {
588
            if (LOG.isLoggable(Level.FINEST)) {
Lines 585-591 Link Here
585
     * @see Caret#moveDot(int) 
616
     * @see Caret#moveDot(int) 
586
     */
617
     */
587
    public @Override void moveDot(final int offset) {
618
    public @Override void moveDot(final int offset) {
588
        moveDot(offset, MoveCaretsOrigin.DEFAULT);
619
        moveDot(offset, Position.Bias.Forward, MoveCaretsOrigin.DEFAULT);
589
    }
620
    }
590
    
621
    
591
    /**
622
    /**
Lines 603-613 Link Here
603
     * </p>
634
     * </p>
604
     * 
635
     * 
605
     * @param offset new offset for the caret
636
     * @param offset new offset for the caret
637
     * @param bias new bias for the caret. Use either {@link Position.Bias.Forward}
638
     *  or {@link Position.Bias.Backward} depending on whether the caret should bias
639
     *  towards the next character or previous one. Use forward bias for non-bidirectional text document.
606
     * @param orig specifies the operation which caused the caret to move.
640
     * @param orig specifies the operation which caused the caret to move.
607
     * @see #moveDot(int) 
641
     * @see #moveDot(int) 
608
     * @since 2.10
642
     * @since 2.10
609
     */
643
     */
610
    public void moveDot(final int offset, MoveCaretsOrigin orig) {
644
    public void moveDot(final int offset, Position.Bias bias, MoveCaretsOrigin orig) {
611
        if (LOG.isLoggable(Level.FINE)) {
645
        if (LOG.isLoggable(Level.FINE)) {
612
            LOG.fine("moveDot: offset=" + offset); //NOI18N
646
            LOG.fine("moveDot: offset=" + offset); //NOI18N
613
        }
647
        }
Lines 719-736 Link Here
719
     * </pre>
753
     * </pre>
720
     * 
754
     * 
721
     * @param dotPos position of the newly created caret.
755
     * @param dotPos position of the newly created caret.
756
     * @param dotBias bias of the new caret. Use either {@link Position.Bias.Forward}
757
     *  or {@link Position.Bias.Backward} depending on whether the caret should bias
758
     *  towards the next character or previous one. Use forward bias for non-bidirectional text document.
722
     * @param markPos beginning of the selection (the other end is dotPos) or the same position like dotPos for no selection.
759
     * @param markPos beginning of the selection (the other end is dotPos) or the same position like dotPos for no selection.
723
     *  The markPos may have higher offset than dotPos to select in a backward direction.
760
     *  The markPos may have higher offset than dotPos to select in a backward direction.
761
     * @param markBias bias of the begining of the selection. Use either {@link Position.Bias.Forward}
762
     *  or {@link Position.Bias.Backward} depending on whether the caret should bias
763
     *  towards the next character or previous one. Use forward bias for non-bidirectional text document.
724
     * @return difference between current count of carets and the number of carets when the operation started.
764
     * @return difference between current count of carets and the number of carets when the operation started.
725
     *  Returns Integer.MIN_VALUE if the operation was cancelled due to the caret not being installed in any text component
765
     *  Returns Integer.MIN_VALUE if the operation was canceled due to the caret not being installed in any text component
726
     *  or no document installed in the text component.
766
     *  or no document installed in the text component.
727
     *  <br>
767
     *  <br>
728
     *  Note that adding a new caret to offset where another caret is already located may lead
768
     *  Note that adding a new caret to offset where another caret is already located may lead
729
     *  or no document installed in the text component.
769
     *  or no document installed in the text component.
730
     */
770
     */
731
    public int addCaret(@NonNull Position dotPos, @NonNull Position markPos) {
771
    public int addCaret(@NonNull Position dotPos, @NonNull Position.Bias dotBias,
772
            @NonNull Position markPos, @NonNull Position.Bias markBias)
773
    {
732
        return runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0,
774
        return runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0,
733
                new CaretItem[] { new CaretItem(this, dotPos, markPos) }, null);
775
                new CaretItem[] { new CaretItem(this, dotPos, dotBias, markPos, markBias) }, null);
734
    }
776
    }
735
    
777
    
736
    /**
778
    /**
Lines 758-770 Link Here
758
     * @param dotAndMarkPosPairs list of position pairs consisting of dot position
800
     * @param dotAndMarkPosPairs list of position pairs consisting of dot position
759
     *  and mark position (selection start position) which may be the same position like the dot
801
     *  and mark position (selection start position) which may be the same position like the dot
760
     *  if the particular caret has no selection. The list must have even size.
802
     *  if the particular caret has no selection. The list must have even size.
803
     * @param dotAndMarkBiases list of position biases (corresponding to the dot and mark positions
804
     *  in the previous parameter) or null may be passed if all dotAndMarkPosPairs positions should have a forward bias.
761
     * @return difference between current count of carets and the number of carets when the operation started.
805
     * @return difference between current count of carets and the number of carets when the operation started.
762
     *  Returns Integer.MIN_VALUE if the operation was cancelled due to the caret not being installed in any text component
806
     *  Returns Integer.MIN_VALUE if the operation was canceled due to the caret not being installed in any text component
763
     *  or no document installed in the text component.
807
     *  or no document installed in the text component.
808
     * @see #addCaret(javax.swing.text.Position, javax.swing.text.Position.Bias, javax.swing.text.Position, javax.swing.text.Position.Bias)
764
     */
809
     */
765
    public int addCarets(@NonNull List<Position> dotAndMarkPosPairs) {
810
    public int addCarets(@NonNull List<Position> dotAndMarkPosPairs, List<Position.Bias> dotAndMarkBiases) {
766
        return runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0,
811
        return runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0,
767
                CaretTransaction.asCaretItems(this, dotAndMarkPosPairs), null);
812
                CaretTransaction.asCaretItems(this, dotAndMarkPosPairs, dotAndMarkBiases), null);
768
    }
813
    }
769
814
770
    /**
815
    /**
Lines 776-790 Link Here
776
     * @param dotAndMarkPosPairs list of position pairs consisting of dot position
821
     * @param dotAndMarkPosPairs list of position pairs consisting of dot position
777
     *  and mark position (selection start position) which may be the same position like dot
822
     *  and mark position (selection start position) which may be the same position like dot
778
     *  if the particular caret has no selection. The list must have even size.
823
     *  if the particular caret has no selection. The list must have even size.
824
     * @param dotAndMarkBiases list of position biases (corresponding to the dot and mark positions
825
     *  in the previous parameter) or null may be passed if all dotAndMarkPosPairs positions should have a forward bias.
779
     * @return difference between current count of carets and the number of carets when the operation started.
826
     * @return difference between current count of carets and the number of carets when the operation started.
780
     *  Returns Integer.MIN_VALUE if the operation was cancelled due to the caret not being installed in any text component
827
     *  Returns Integer.MIN_VALUE if the operation was cancelled due to the caret not being installed in any text component
781
     *  or no document installed in the text component.
828
     *  or no document installed in the text component.
782
     */
829
     */
783
    public int replaceCarets(@NonNull List<Position> dotAndMarkPosPairs) {
830
    public int replaceCarets(@NonNull List<Position> dotAndMarkPosPairs, List<Position.Bias> dotAndMarkBiases) {
784
        if (dotAndMarkPosPairs.isEmpty()) {
831
        if (dotAndMarkPosPairs.isEmpty()) {
785
            throw new IllegalArgumentException("dotAndSelectionStartPosPairs list must not be empty");
832
            throw new IllegalArgumentException("dotAndSelectionStartPosPairs list must not be empty");
786
        }
833
        }
787
        CaretItem[] addedItems = CaretTransaction.asCaretItems(this, dotAndMarkPosPairs);
834
        CaretItem[] addedItems = CaretTransaction.asCaretItems(this, dotAndMarkPosPairs, dotAndMarkBiases);
788
        return runTransaction(CaretTransaction.RemoveType.REMOVE_ALL_CARETS, 0, addedItems, null);
835
        return runTransaction(CaretTransaction.RemoveType.REMOVE_ALL_CARETS, 0, addedItems, null);
789
    }
836
    }
790
837
Lines 1784-1790 Link Here
1784
1831
1785
            // Set caret to zero position upon document change (DefaultCaret impl does this too)
1832
            // Set caret to zero position upon document change (DefaultCaret impl does this too)
1786
            runTransaction(CaretTransaction.RemoveType.REMOVE_ALL_CARETS, 0,
1833
            runTransaction(CaretTransaction.RemoveType.REMOVE_ALL_CARETS, 0,
1787
                    new CaretItem[] { new CaretItem(this, newDoc.getStartPosition(), null) }, null);
1834
                    new CaretItem[] { new CaretItem(this, newDoc.getStartPosition(), Position.Bias.Forward,
1835
                            null, Position.Bias.Forward ) }, null);
1788
            
1836
            
1789
            // Leave caretPos and markPos null => offset==0
1837
            // Leave caretPos and markPos null => offset==0
1790
            prefs = (mimeType != null) ? MimeLookup.getLookup(mimeType).lookup(Preferences.class) : null;
1838
            prefs = (mimeType != null) ? MimeLookup.getLookup(mimeType).lookup(Preferences.class) : null;
Lines 2576-2582 Link Here
2576
                                try {
2624
                                try {
2577
                                    Position pos = doc.createPosition(offset);
2625
                                    Position pos = doc.createPosition(offset);
2578
                                    runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0, 
2626
                                    runTransaction(CaretTransaction.RemoveType.NO_REMOVE, 0, 
2579
                                             new CaretItem[] { new CaretItem(EditorCaret.this, pos, pos) }, null);
2627
                                             new CaretItem[] { new CaretItem(EditorCaret.this, pos, Position.Bias.Forward,
2628
                                                     pos, Position.Bias.Forward) }, null);
2580
                                } catch (BadLocationException ex) {
2629
                                } catch (BadLocationException ex) {
2581
                                    // Do nothing
2630
                                    // Do nothing
2582
                                }
2631
                                }
(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/CaretUndoEdit.java (-3 / +3 lines)
Lines 66-72 Link Here
66
    final Document doc; // (16=super)+4=20 bytes
66
    final Document doc; // (16=super)+4=20 bytes
67
    
67
    
68
    /**
68
    /**
69
     * Offset of the dot to restore and last bit is a marker for undo/redo
69
     * Offset of the dot to restore and last bit is a marker for position bias - TODO
70
     */
70
     */
71
    private int dotOffset; // 24 bytes
71
    private int dotOffset; // 24 bytes
72
    
72
    
Lines 116-122 Link Here
116
116
117
    protected void restoreEditorCaret(EditorCaret caret) throws BadLocationException {
117
    protected void restoreEditorCaret(EditorCaret caret) throws BadLocationException {
118
        Position dotPos = doc.createPosition(getDotOffset());
118
        Position dotPos = doc.createPosition(getDotOffset());
119
        caret.replaceCarets(Arrays.asList(dotPos, dotPos));
119
        caret.replaceCarets(Arrays.asList(dotPos, dotPos), null); // TODO handle biases
120
    }
120
    }
121
    
121
    
122
    protected void restoreLegacyCaret(Caret caret) {
122
    protected void restoreLegacyCaret(Caret caret) {
Lines 177-183 Link Here
177
                    splitOffset = extraDotAndMarkOffsets[i++];
177
                    splitOffset = extraDotAndMarkOffsets[i++];
178
                }
178
                }
179
            }
179
            }
180
            caret.replaceCarets(dotAndMarkPosPairs);
180
            caret.replaceCarets(dotAndMarkPosPairs, null); // TODO handle biases
181
        }
181
        }
182
182
183
        @Override
183
        @Override
(-)a/editor.search/src/org/netbeans/modules/editor/search/EditorFindSupport.java (-1 / +2 lines)
Lines 451-457 Link Here
451
        if (eCaret instanceof EditorCaret) {
451
        if (eCaret instanceof EditorCaret) {
452
            EditorCaret caret = (EditorCaret) eCaret;
452
            EditorCaret caret = (EditorCaret) eCaret;
453
            try {
453
            try {
454
                caret.addCaret(c.getDocument().createPosition(end), c.getDocument().createPosition(start));
454
                caret.addCaret(c.getDocument().createPosition(end), Position.Bias.Forward,
455
                    c.getDocument().createPosition(start), Position.Bias.Forward);
455
            } catch (BadLocationException ex) {
456
            } catch (BadLocationException ex) {
456
                Exceptions.printStackTrace(ex);
457
                Exceptions.printStackTrace(ex);
457
            }
458
            }
(-)a/editor.search/src/org/netbeans/modules/editor/search/SearchBar.java (-1 / +1 lines)
Lines 947-953 Link Here
947
                        newCarets.add(startPos);
947
                        newCarets.add(startPos);
948
                    }
948
                    }
949
                    
949
                    
950
                    editorCaret.replaceCarets(newCarets);
950
                    editorCaret.replaceCarets(newCarets, null); // TODO handle biases
951
                    
951
                    
952
                    textComponent.requestFocusInWindow();
952
                    textComponent.requestFocusInWindow();
953
                }
953
                }
(-)a/editor.search/src/org/netbeans/modules/editor/search/actions/AddCaretSelectAllAction.java (-1 / +1 lines)
Lines 130-136 Link Here
130
                                newCarets.add(startPos);
130
                                newCarets.add(startPos);
131
                            }
131
                            }
132
132
133
                            editorCaret.replaceCarets(newCarets);
133
                            editorCaret.replaceCarets(newCarets, null); // TODO handle biases
134
                        }
134
                        }
135
                    } catch (BadLocationException ex) {
135
                    } catch (BadLocationException ex) {
136
                        Exceptions.printStackTrace(ex);
136
                        Exceptions.printStackTrace(ex);

Return to bug 259023