Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
271,900
void () { initText("text"); addBlockInlay(0, true, 10 * TEST_CHAR_WIDTH); EditorTestUtil.setEditorVisibleSize(getEditor(), 100, 100); mouse().pressAtXY(2 * TEST_CHAR_WIDTH, 0).dragToXY(4 * TEST_CHAR_WIDTH, 0).release(); checkResultByText("<caret>text"); }
testDragInBlockInlayDoesNotCreateSelection
271,901
void () { initText("text"); addBlockInlay(0, true); EditorTestUtil.setEditorVisibleSize(getEditor(), 100, 100); mouse().pressAtXY(2 * TEST_CHAR_WIDTH, (int)(getEditor().getLineHeight() * 1.5)).dragToXY(-1, -1).release(); checkResultByText("<selection><caret>te</selection>xt"); }
testDragBeyondEditorTopWithBlockInlay
271,902
void () { initText("<caret>abc"); addCollapsedFoldRegion(1, 2, ""); right(); Caret caret = getEditor().getCaretModel().getPrimaryCaret(); assertEquals(2, caret.getOffset()); assertEquals(new LogicalPosition(0, 2), caret.getLogicalPosition()); assertEquals(new VisualPosition(0, 1), caret.getVisualPosition()); right(); assertEquals(3, caret.getOffset()); assertEquals(new LogicalPosition(0, 3), caret.getLogicalPosition()); assertEquals(new VisualPosition(0, 2), caret.getVisualPosition()); }
testCaretMovementAtFoldRegionWithEmptyPlaceholder
271,903
void () { initText("abc<caret>"); addBlockInlay(0, true, 10); EditorTestUtil.setEditorVisibleSize(getEditor(), 100, 100); mouse().pressAtXY(0, 0).dragToXY(0, getEditor().getLineHeight()).release(); checkResultByText("abc<caret>"); }
testDragStartingAtBlockInlay
271,904
void () { boolean savedOption = EditorSettingsExternalizable.getInstance().isCamelWords(); try { EditorSettingsExternalizable.getInstance().setCamelWords(true); initText("AbcDefGhi"); EditorTestUtil.setEditorVisibleSize(getEditor(), 100, 100); getEditor().getSettings().setMouseClickSelectionHonorsCamelWords(false); mouse().doubleClickNoReleaseAt(0, 4).dragTo(0, 5).release(); checkResultByText("<selection>AbcDefGhi<caret></selection>"); } finally { EditorSettingsExternalizable.getInstance().setCamelWords(savedOption); } }
testMouseDraggingWithCamelHumpsDisabledForMouse
271,905
void () { initText(""); EditorColorsScheme colorsScheme = getEditor().getColorsScheme(); FontPreferencesImpl preferences = new FontPreferencesImpl(); preferences.register("CustomFont", 32); preferences.setUseLigatures(true); colorsScheme.setFontPreferences(preferences); FontPreferences p = colorsScheme.getFontPreferences(); assertEquals(Collections.singletonList("CustomFont"), p.getRealFontFamilies()); assertEquals(32, p.getSize("CustomFont")); assertTrue(p.useLigatures()); FontPreferencesImpl preferences2 = new FontPreferencesImpl(); preferences2.register("CustomFont2", 23); preferences2.setUseLigatures(false); colorsScheme.setFontPreferences(preferences2); FontPreferences p2 = colorsScheme.getFontPreferences(); assertEquals(Collections.singletonList("CustomFont2"), p2.getRealFontFamilies()); assertEquals(23, p2.getSize("CustomFont2")); assertFalse(p.useLigatures()); }
testSettingFontPreferences
271,906
void () { initText("Some long line of text"); configureSoftWraps(15); // emulate adding editor to a wide component SoftWrapApplianceManager.VisibleAreaWidthProvider widthProvider = ((SoftWrapModelImpl)getEditor().getSoftWrapModel()).getApplianceManager().getWidthProvider(); ((EditorTestUtil.TestWidthProvider)widthProvider).setVisibleAreaWidth(1_000_000); new JPanel().add(getEditor().getComponent()); runWriteCommand(() -> getEditor().getDocument().insertString(0, " ")); verifySoftWrapPositions(); }
testDocumentChangeAfterWidthChange
271,907
void () { initText("<selection>text<caret></selection>"); addBlockInlay(0, true, 100); mouse().clickAtXY(50, getEditor().getLineHeight() / 2); checkResultByText("<selection>text<caret></selection>"); }
testClickOnBlockInlayDoesNotRemoveSelection
271,908
void () { initText("((some (text)))"); EditorTestUtil.setEditorVisibleSize(getEditor(), 100, 100); mouse().doubleClickNoReleaseAt(0, 4).dragTo(0, 12).release(); checkResultByText("((<selection>some (text)<caret></selection>))"); }
testWordSelectionOnMouseDragAroundPunctuation
271,909
void () { initText("ab<caret>cd"); ((EditorEx)getEditor()).setInsertMode(false); JComponent component = getEditor().getContentComponent(); component.dispatchEvent(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, new AttributedString("\uD83D\uDE00" /* 'GRINNING FACE' emoji (U+1F600) */).getIterator(), 2, null, null)); checkResultByText("ab\uD83D\uDE00d"); }
testSurrogatePairInputInOverwriteMode
271,910
void () { initText("hello<caret>"); JComponent component = getEditor().getContentComponent(); component.dispatchEvent(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, new AttributedString("\u3145" /* ㅅ */).getIterator(), 0, TextHitInfo.afterOffset(0), TextHitInfo.afterOffset(-1))); component.dispatchEvent(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, new AttributedString("\u3146" /* ㅆ */).getIterator(), 0, TextHitInfo.afterOffset(0), TextHitInfo.afterOffset(-1))); checkResultByText("hello\u3146"); }
testInputMethodComposing
271,911
void () { initText("hello<caret>"); JComponent component = getEditor().getContentComponent(); component.dispatchEvent(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, new AttributedString("\u3145" /* ㅅ */).getIterator(), 0, null, null)); component.dispatchEvent(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, new AttributedString("\u3146" /* ㅆ */).getIterator(), 0, null, null)); mouse().clickAtXY(0, getEditor().getLineHeight() / 2); checkResultByText("<caret>hello\u3146"); }
testInputMethodCaretMove
271,912
void () { FontLayoutService.setInstance(new MockFontLayoutService(cp -> cp == 'Z' ? 2 * TEST_CHAR_WIDTH : TEST_CHAR_WIDTH, TEST_LINE_HEIGHT, TEST_DESCENT)); initText(StringUtil.repeatSymbol('Z', 500) + "<caret>"); setEditorVisibleSize(100, 100); type(' '); Rectangle visibleArea = getEditor().getScrollingModel().getVisibleAreaOnScrollingFinished(); Point caretPosition = getEditor().visualPositionToXY(getEditor().getCaretModel().getVisualPosition()); assertTrue(visibleArea.contains(caretPosition)); }
testScrollingToCaretWithWideCharacters
271,913
void () { Registry.get("editor.block.caret.selection.vim-like").setValue(true, getTestRootDisposable()); initText("abcdef"); EditorTestUtil.setEditorVisibleSize(getEditor(), 1000, 1000); // enable drag testing getEditor().getSettings().setBlockCursor(true); int y = getEditor().getLineHeight() / 2; mouse().pressAtXY(3 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<caret>def"); mouse().dragToXY(3 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<caret>def"); mouse().dragToXY(2 * TEST_CHAR_WIDTH + 1, y); checkResultByText("ab<selection><caret>cd</selection>ef"); mouse().dragToXY(TEST_CHAR_WIDTH + 1, y); checkResultByText("a<selection><caret>bcd</selection>ef"); mouse().dragToXY(2 * TEST_CHAR_WIDTH + 1, y); checkResultByText("ab<selection><caret>cd</selection>ef"); mouse().dragToXY(3 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<selection><caret>d</selection>ef"); mouse().dragToXY(4 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<selection>d<caret>e</selection>f"); mouse().dragToXY(5 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<selection>de<caret>f</selection>"); mouse().dragToXY(2 * TEST_CHAR_WIDTH + 1, y); checkResultByText("ab<selection><caret>cd</selection>ef"); mouse().dragToXY(5 * TEST_CHAR_WIDTH + 1, y); checkResultByText("abc<selection>de<caret>f</selection>"); }
testMouseSelectionWithBlockCaret
271,914
void () { Registry.get("editor.block.caret.selection.vim-like").setValue(true, getTestRootDisposable()); initText("abc\ndef"); EditorTestUtil.setEditorVisibleSize(getEditor(), 1000, 1000); // enable drag testing getEditor().getSettings().setBlockCursor(true); int line1Y = getEditor().getLineHeight() / 2; int line2Y = getEditor().getLineHeight() * 3 / 2; mouse().pressAtXY(3 * TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("abc<caret>\ndef"); mouse().dragToXY(3 * TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("abc<caret>\ndef"); mouse().dragToXY(2 * TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("ab<selection><caret>c\n</selection>def"); mouse().dragToXY(TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("a<selection><caret>bc\n</selection>def"); mouse().dragToXY(2 * TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("ab<selection><caret>c\n</selection>def"); mouse().dragToXY(3 * TEST_CHAR_WIDTH + 1, line1Y); checkResultByText("abc<selection><caret>\n</selection>def"); mouse().dragToXY(3 * TEST_CHAR_WIDTH + 1, line2Y); checkResultByText("abc<selection>\ndef<caret></selection>"); mouse().dragToXY(1, line2Y); checkResultByText("abc<selection>\n<caret>d</selection>ef"); mouse().dragToXY(1, line1Y); checkResultByText("<selection><caret>abc\n</selection>def"); }
testMouseSelectionAtLineEndWithBlockCaret
271,915
void () { if (!SystemInfo.isMac) return; // macOS-specific test initText("<caret>b"); JComponent component = getEditor().getContentComponent(); // 'A' key pressed dispatchEventToEditor(new KeyEvent(component, KeyEvent.KEY_PRESSED, 0, 0, KeyEvent.VK_A, 'a', KeyEvent.KEY_LOCATION_STANDARD)); dispatchEventToEditor(new KeyEvent(component, KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a', KeyEvent.KEY_LOCATION_UNKNOWN)); checkResultByText("a<caret>b"); // popup with diacritic appears while key is held pressed requestSelectedTextFromEditorViaImeApi(); checkResultByText("a<caret>b"); // 'A' key released dispatchEventToEditor(new KeyEvent(component, KeyEvent.KEY_RELEASED, 1, 0, KeyEvent.VK_A, 'a', KeyEvent.KEY_LOCATION_STANDARD)); checkResultByText("a<caret>b"); // 'Right arrow' key pressed to select first variant from the popup requestSelectedTextFromEditorViaImeApi(); dispatchEventToEditor(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, 2, new AttributedString("\u00e0" /* LATIN SMALL LETTER A WITH GRAVE */).getIterator(), 0, null, TextHitInfo.beforeOffset(0))); checkResultByText("\u00e0b"); // not checking caret/selection state, as we don't need to enforce the behaviour as of test creation time // 'Right arrow' key released dispatchEventToEditor(new KeyEvent(component, KeyEvent.KEY_RELEASED, 3, 0, KeyEvent.VK_RIGHT, KeyEvent.CHAR_UNDEFINED, KeyEvent.KEY_LOCATION_STANDARD)); checkResultByText("\u00e0b"); // not checking caret/selection state, as we don't need to enforce the behaviour as of test creation time // 'Enter' key pressed to confirm selected variant requestSelectedTextFromEditorViaImeApi(); dispatchEventToEditor(new InputMethodEvent(component, InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, 4, new AttributedString("\u00e0" /* LATIN SMALL LETTER A WITH GRAVE */).getIterator(), 1, TextHitInfo.afterOffset(0), TextHitInfo.afterOffset(0))); checkResultByText("\u00e0<caret>b"); // 'Enter' key released dispatchEventToEditor(new KeyEvent(component, KeyEvent.KEY_RELEASED, 5, 0, KeyEvent.VK_ENTER, '\n', KeyEvent.KEY_LOCATION_STANDARD)); checkResultByText("\u00e0<caret>b"); }
testPressAndHoldInputMethodOnMac
271,916
void (AWTEvent event) { // this method ensures key events are dispatched to editor component, even if it's not focused KeyboardFocusManager.getCurrentKeyboardFocusManager().redispatchEvent(getEditor().getContentComponent(), event); }
dispatchEventToEditor
271,917
void () { getEditor().getContentComponent().getInputMethodRequests().getSelectedText(null); }
requestSelectedTextFromEditorViaImeApi
271,918
RangeMarker (final int start, final int end) { final Document document = myFixture.getEditor().getDocument(); return document.createGuardedBlock(start, end); }
createGuard
271,919
void () { myFixture.configureByText("x.txt", "xxxx"); RangeMarker guard = createGuard(0, 0); guard.setGreedyToLeft(true); guard.setGreedyToRight(true); checkUnableToTypeIn(0); checkCanTypeIn(1); }
testZero
271,920
void () { myFixture.configureByText("x.txt", "xxxxxxxx"); createGuard(1, 4); checkUnableToTypeIn(2); checkCanTypeIn(0); }
testInTheMiddle
271,921
void () { myFixture.configureByText("x.txt", "012345678"); { RangeMarker guard = createGuard(0, 5); guard.setGreedyToLeft(true); guard.setGreedyToRight(false); } { RangeMarker guard = createGuard(5, 6); guard.setGreedyToLeft(false); guard.setGreedyToRight(true); } checkCanTypeIn(5); checkUnableToTypeIn(0); }
testGreedy
271,922
void () { myFixture.configureByText("x.txt", "012345678"); { RangeMarker guard = createGuard(0, 5); guard.setGreedyToLeft(true); guard.setGreedyToRight(true); } checkUnableToTypeIn(5); }
testGreedyEnd
271,923
void (int offset) { String text = myFixture.getEditor().getDocument().getText(); try { myFixture.getEditor().getCaretModel().moveToOffset(offset); myFixture.type("y"); } catch (RuntimeException e) { assertEquals("Unable to perform an action since it changes read-only fragments of the current document",e.getMessage()); assertEquals(text, myFixture.getEditor().getDocument().getText()); return; } fail("must be read only at "+offset); }
checkUnableToTypeIn
271,924
void (int offset) { myFixture.getEditor().getCaretModel().moveToOffset(offset); myFixture.type("yy"); }
checkCanTypeIn
271,925
void () { String text = "abc abd a<caret> abx"; myFixture.configureByText("x.txt", text); int offset = myFixture.getEditor().getCaretModel().getOffset(); createGuard(offset - 1, myFixture.getFile().getTextLength()).setGreedyToRight(true); assertNull(myFixture.completeBasic()); myFixture.checkResult(text); //no hippie completion myFixture.performEditorAction(IdeActions.ACTION_HIPPIE_BACKWARD_COMPLETION); assertNull(LookupManager.getInstance(getProject()).getActiveLookup()); myFixture.checkResult(text); //no completion at the file end myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getFile().getTextLength()); assertNull(myFixture.completeBasic()); myFixture.checkResult("abc abd a abx<caret>"); //completion at the beginning of the guard fragment myFixture.getEditor().getCaretModel().moveToOffset(offset - 1); assertNotNull(myFixture.completeBasic()); }
testNoCompletion
271,926
void () { String text = "a\n#%%\nc"; // ^^^^^^^ <- guarded // com.intellij.openapi.editor.actions.DocumentGuardedTextUtil.insertString handles this case and inserts "\na" after first "a" myFixture.configureByText("x.txt", text); RangeMarker guard = createGuard(1, 6); myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DUPLICATE_LINES); myFixture.checkResult("a\na\n#%%\nc"); assertTrue(guard.isValid()); assertEquals(3, guard.getStartOffset()); assertEquals(8, guard.getEndOffset()); }
testDocumentGuardedTextUtilDuplicateLine
271,927
void () { String text = "a\n<caret>b\n#%%\nc"; // ^^^^^^^ <- guarded // com.intellij.openapi.editor.actions.DocumentGuardedTextUtil.deleteString handles this case and removes \n before caret myFixture.configureByText("x.txt", text); RangeMarker guard = createGuard(3, 8); myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DELETE_LINE); myFixture.checkResult("a\n#%%\nc"); assertTrue(guard.isValid()); assertEquals(1, guard.getStartOffset()); assertEquals(6, guard.getEndOffset()); }
testDocumentGuardedTextUtilDeleteLine
271,928
void () { String text = "a\n#%%\nc"; // ^^^^^^^ <- guarded myFixture.configureByText("x.txt", text); createGuard(1, 6).setGreedyToLeft(true); try { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DUPLICATE_LINES); } catch (RuntimeException e) { assertEquals("Unable to perform an action since it changes read-only fragments of the current document", e.getMessage()); myFixture.checkResult(text); return; } fail("must be read only at " + 1); }
testDocumentGuardedTextUtilDuplicateLineWithGreedy
271,929
void () { String text = "a\n<caret>b\n#%%\nc"; // ^^^^^^^ <- guarded myFixture.configureByText("x.txt", text); createGuard(3, 8).setGreedyToLeft(true); try { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_DELETE_LINE); } catch (RuntimeException e) { assertEquals("Unable to perform an action since it changes read-only fragments of the current document", e.getMessage()); myFixture.checkResult(text); return; } fail("must be read only at " + 3); }
testDocumentGuardedTextUtilDeleteLineWithGreedy
271,930
boolean () { // Otherwise undoing doesn't work return false; }
isRunInCommand
271,931
void () { @SuppressWarnings("SpellCheckingInspection") /* * ( 0th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ( 1st) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ... * caret * v * (10th) Lorem ipsum dolor sit amet, |consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * the text to be typed: "unus duo tres " * ... * (29th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. */ final int caretInitialLineIndex = 10; final int caretInitialColumnIndex = 28; final int caretInitialDot = caretInitialLineIndex * (LOREM_IPSUM.length() + 1) + caretInitialColumnIndex; final EditorImpl editor = initEditor( StringUtil.repeat(LOREM_IPSUM + '\n', 30), caretInitialLineIndex, caretInitialColumnIndex, caretInitialDot ); doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> type('u'), new CaretPos(caretInitialDot + 1, caretInitialDot + 1)), new CaretAction(() -> type('n'), new CaretPos(caretInitialDot + 2, caretInitialDot + 2)), new CaretAction(() -> type('u'), new CaretPos(caretInitialDot + 3, caretInitialDot + 3)), new CaretAction(() -> type('s'), new CaretPos(caretInitialDot + 4, caretInitialDot + 4)), new CaretAction(() -> type(' '), new CaretPos(caretInitialDot + 5, caretInitialDot + 5)), new CaretAction(() -> type('d'), new CaretPos(caretInitialDot + 6, caretInitialDot + 6)), new CaretAction(() -> type('u'), new CaretPos(caretInitialDot + 7, caretInitialDot + 7)), new CaretAction(() -> type('o'), new CaretPos(caretInitialDot + 8, caretInitialDot + 8)), new CaretAction(() -> type(' '), new CaretPos(caretInitialDot + 9, caretInitialDot + 9)), new CaretAction(() -> type('t'), new CaretPos(caretInitialDot + 10, caretInitialDot + 10)), new CaretAction(() -> type('r'), new CaretPos(caretInitialDot + 11, caretInitialDot + 11)), new CaretAction(() -> type('e'), new CaretPos(caretInitialDot + 12, caretInitialDot + 12)), new CaretAction(() -> type('s'), new CaretPos(caretInitialDot + 13, caretInitialDot + 13)), new CaretAction(() -> type(' '), new CaretPos(caretInitialDot + 14, caretInitialDot + 14)) ); }
testCaretNotificationsDuringTyping
271,932
void () { @SuppressWarnings("SpellCheckingInspection") /* * caret * (initial pos) * v * (0th) |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 1. Caret left x 2 (no notifications are expected) * 2. Caret up x 2 (no notifications are expected) * 3. Caret right x 5 * 4. Caret down x 2 * * (1st) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret * (after step 4) * v * (2nd) Lorem| ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 5. Caret up x 1 * 6. Caret right x 6 * 7. Caret down x 3 * * (3rd) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret caret * (after step 7) (after step 11) * v v * (4th) Lorem ipsum| dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.| * ^ ^ * Actions from here: Actions from here: * 8. Caret up x 1 12. Caret right x 2 (no notifications are expected) * 9. Caret down x 1 13. Caret down x 2 (no notifications are expected) * 10. Caret left x 6 * 11. Move caret to the end of the line */ final EditorImpl editor = initEditor(StringUtil.repeat(LOREM_IPSUM + '\n', 4) + LOREM_IPSUM, 0, 0, 0); //noinspection DuplicateExpressions doTestCaretNotifications( editor.getContentComponent(), // step 1 new CaretAction(() -> left(), null), new CaretAction(() -> left(), null), // step 2 new CaretAction(() -> up(), null), new CaretAction(() -> up(), null), // step 3 new CaretAction(() -> right(), new CaretPos(1, 1)), new CaretAction(() -> right(), new CaretPos(2, 2)), new CaretAction(() -> right(), new CaretPos(3, 3)), new CaretAction(() -> right(), new CaretPos(4, 4)), new CaretAction(() -> right(), new CaretPos(5, 5)), // step 4 new CaretAction(() -> down(), new CaretPos(5 + (LOREM_IPSUM.length() + 1), 5 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> down(), new CaretPos(5 + 2 * (LOREM_IPSUM.length() + 1), 5 + 2 * (LOREM_IPSUM.length() + 1))), // step 5 new CaretAction(() -> up(), new CaretPos(5 + (LOREM_IPSUM.length() + 1), 5 + (LOREM_IPSUM.length() + 1))), // step 6 new CaretAction(() -> right(), new CaretPos(6 + (LOREM_IPSUM.length() + 1), 6 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> right(), new CaretPos(7 + (LOREM_IPSUM.length() + 1), 7 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> right(), new CaretPos(8 + (LOREM_IPSUM.length() + 1), 8 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> right(), new CaretPos(9 + (LOREM_IPSUM.length() + 1), 9 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> right(), new CaretPos(10 + (LOREM_IPSUM.length() + 1), 10 + (LOREM_IPSUM.length() + 1))), new CaretAction(() -> right(), new CaretPos(11 + (LOREM_IPSUM.length() + 1), 11 + (LOREM_IPSUM.length() + 1))), // step 7 new CaretAction(() -> down(), new CaretPos(11 + 2 * (LOREM_IPSUM.length() + 1), 11 + 2 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> down(), new CaretPos(11 + 3 * (LOREM_IPSUM.length() + 1), 11 + 3 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> down(), new CaretPos(11 + 4 * (LOREM_IPSUM.length() + 1), 11 + 4 * (LOREM_IPSUM.length() + 1))), // step 8 new CaretAction(() -> up(), new CaretPos(11 + 3 * (LOREM_IPSUM.length() + 1), 11 + 3 * (LOREM_IPSUM.length() + 1))), // step 9 new CaretAction(() -> down(), new CaretPos(11 + 4 * (LOREM_IPSUM.length() + 1), 11 + 4 * (LOREM_IPSUM.length() + 1))), // step 10 new CaretAction(() -> left(), new CaretPos(10 + 4 * (LOREM_IPSUM.length() + 1), 10 + 4 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> left(), new CaretPos(9 + 4 * (LOREM_IPSUM.length() + 1), 9 + 4 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> left(), new CaretPos(8 + 4 * (LOREM_IPSUM.length() + 1), 8 + 4 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> left(), new CaretPos(7 + 4 * (LOREM_IPSUM.length() + 1), 7 + 4 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> left(), new CaretPos(6 + 4 * (LOREM_IPSUM.length() + 1), 6 + 4 * (LOREM_IPSUM.length() + 1))), new CaretAction(() -> left(), new CaretPos(5 + 4 * (LOREM_IPSUM.length() + 1), 5 + 4 * (LOREM_IPSUM.length() + 1))), // step 11 new CaretAction(() -> end(), new CaretPos(LOREM_IPSUM.length() + 4 * (LOREM_IPSUM.length() + 1), LOREM_IPSUM.length() + 4 * (LOREM_IPSUM.length() + 1))), // step 12 new CaretAction(() -> right(), null), new CaretAction(() -> right(), null), // step 13 new CaretAction(() -> down(), null), new CaretAction(() -> down(), null) ); }
testCaretNotificationsOfCaretMovementsWithoutTextModifications
271,933
void () { // Any attempts to move the caret within an empty editor aren't supposed to cause caret movements => no caret updates are expected. final EditorImpl editor = initEditor("", 0, 0, 0); doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> left(), null), new CaretAction(() -> right(), null), new CaretAction(() -> up(), null), new CaretAction(() -> down(), null), new CaretAction(() -> left(), null), new CaretAction(() -> down(), null), new CaretAction(() -> right(), null), new CaretAction(() -> up(), null) ); }
testCaretNotificationsWithinEmptyEditor
271,934
void () { // Undoing a modifying operation near the caret has to cause a caret update notification // The initial configuration is the same as the testCaretNotificationsDuringTyping's one final int caretInitialLineIndex = 10; final int caretInitialColumnIndex = 28; final int caretInitialDot = caretInitialLineIndex * (LOREM_IPSUM.length() + 1) + caretInitialColumnIndex; final EditorImpl editor = initEditor( StringUtil.repeat(LOREM_IPSUM + '\n', 30), caretInitialLineIndex, caretInitialColumnIndex, caretInitialDot ); // copy "unus duo tres " to the clipboard CopyPasteManager.getInstance().setContents(new StringSelection("unus duo tres ")); EditorTestUtil.testUndoInEditor(editor, () -> { doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> paste(), new CaretPos(caretInitialDot + 14, caretInitialDot + 14)), new CaretAction(() -> undo(), new CaretPos(caretInitialDot, caretInitialDot)) ); }); }
testCaretNotificationsCausedByUndo
271,935
void () { @SuppressWarnings("SpellCheckingInspection") /* * dot and mark * (initial pos and after step 15) * v * (0th) |$Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 1. Left with selection x 2 (no notifications are expected) * 2. Up with selection x 2 (no notifications are expected) * 3. Left with selection (no notifications are expected) * 4. Up with selection (no notifications are expected) * 5. Right with selection x 3 * 6. Down with selection x 2 * 7. Right with selection * 8. Down with selection * 9. Right with selection * 10. Down with selection x 2 * * (1st) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (2nd) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (3rd) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (4th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * dot * (after step 10) * v * (5th) Lorem$ ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 11. Up with selection x 3 * 12. Down with selection * 13. Up with selection x 2 * 14. Left by word with selection * 15. Up with selection */ final var editor = initEditor(StringUtil.repeat(LOREM_IPSUM + '\n', 5) + LOREM_IPSUM, 0, 0, 0); //noinspection DuplicateExpressions doTestCaretNotifications( editor.getContentComponent(), // step 1 new CaretAction(() -> leftWithSelection(), null), new CaretAction(() -> leftWithSelection(), null), // step 2 new CaretAction(() -> upWithSelection(), null), new CaretAction(() -> upWithSelection(), null), // step 3 new CaretAction(() -> leftWithSelection(), null), // step 4 new CaretAction(() -> upWithSelection(), null), // step 5 new CaretAction(() -> rightWithSelection(), new CaretPos(1, 0)), new CaretAction(() -> rightWithSelection(), new CaretPos(2, 0)), new CaretAction(() -> rightWithSelection(), new CaretPos(3, 0)), // step 6 new CaretAction(() -> downWithSelection(), new CaretPos(3 + (LOREM_IPSUM.length() + 1), 0)), new CaretAction(() -> downWithSelection(), new CaretPos(3 + 2 * (LOREM_IPSUM.length() + 1), 0)), // step 7 new CaretAction(() -> rightWithSelection(), new CaretPos(4 + 2 * (LOREM_IPSUM.length() + 1), 0)), // step 8 new CaretAction(() -> downWithSelection(), new CaretPos(4 + 3 * (LOREM_IPSUM.length() + 1), 0)), // step 9 new CaretAction(() -> rightWithSelection(), new CaretPos(5 + 3 * (LOREM_IPSUM.length() + 1), 0)), // step 10 new CaretAction(() -> downWithSelection(), new CaretPos(5 + 4 * (LOREM_IPSUM.length() + 1), 0)), new CaretAction(() -> downWithSelection(), new CaretPos(5 + 5 * (LOREM_IPSUM.length() + 1), 0)), // step 11 new CaretAction(() -> upWithSelection(), new CaretPos(5 + 4 * (LOREM_IPSUM.length() + 1), 0)), new CaretAction(() -> upWithSelection(), new CaretPos(5 + 3 * (LOREM_IPSUM.length() + 1), 0)), new CaretAction(() -> upWithSelection(), new CaretPos(5 + 2 * (LOREM_IPSUM.length() + 1), 0)), // step 12 new CaretAction(() -> downWithSelection(), new CaretPos(5 + 3 * (LOREM_IPSUM.length() + 1), 0)), // step 13 new CaretAction(() -> upWithSelection(), new CaretPos(5 + 2 * (LOREM_IPSUM.length() + 1), 0)), new CaretAction(() -> upWithSelection(), new CaretPos(5 + (LOREM_IPSUM.length() + 1), 0)), // step 14 new CaretAction(() -> moveCaretToPreviousWordWithSelection(), new CaretPos(LOREM_IPSUM.length() + 1, 0)), // step 15 new CaretAction(() -> upWithSelection(), new CaretPos(0, 0)) ); }
testCaretNotificationsOfSelectionMovementsWithoutTextModificationsFromTopLeft
271,936
void () { @SuppressWarnings("SpellCheckingInspection") /* * (0th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (1st) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (2nd) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * dot and mark * (initial pos and after step 10) * v * (3rd) Lorem ipsum dolor sit amet, |$consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 1. Left with selection x 6 * 2. Right with selection x 3 * 3. Up with selection * 4. Down with selection * 5. Up with selection x 2 * 6. Down with selection x 4 * * (4th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * dot * (after step 6) * v * (5th) Lorem ipsum dolor sit ame$t, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ^ * Actions from here: * 7. Right with selection x 3 * 8. Right by word with selection * 9. Left by word with selection * 10. Up with selection x 2 */ final int initialCaretLine = 3; final int initialCaretColumn = 28; final int initialCaretOffset = initialCaretLine * (LOREM_IPSUM.length() + 1) + initialCaretColumn; final var editor = initEditor(StringUtil.repeat(LOREM_IPSUM + '\n', 5) + LOREM_IPSUM, initialCaretLine, initialCaretColumn, initialCaretOffset); //noinspection DuplicateExpressions,PointlessArithmeticExpression doTestCaretNotifications( editor.getContentComponent(), // step 1 new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 1, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 2, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 3, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 4, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 5, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 6, initialCaretOffset)), // step 2 new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 5, initialCaretOffset)), new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 4, initialCaretOffset)), new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 3, initialCaretOffset)), // step 3 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 3 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 4 new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 3, initialCaretOffset)), // step 5 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 3 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 3 - 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 6 new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 3 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 3, initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 3 + 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 3 + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 7 new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 2 + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 1 + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 8 new CaretAction(() -> moveCaretToNextWordWithSelection(), new CaretPos(initialCaretOffset + 11 + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 9 new CaretAction(() -> moveCaretToPreviousWordWithSelection(), new CaretPos(initialCaretOffset + 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 10 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset + 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset, initialCaretOffset)) ); }
testCaretNotificationsOfSelectionMovementsWithoutTextModificationsFromCenter
271,937
void () { // the "reflection" of the testCaretNotificationsOfSelectionMovementsWithoutTextModificationsFromTopLeft // Bottom right final int initialCaretLine = 5; final int initialCaretColumn = LOREM_IPSUM.length(); final int initialCaretOffset = initialCaretLine * (LOREM_IPSUM.length() + 1) + initialCaretColumn; final var editor = initEditor(StringUtil.repeat(LOREM_IPSUM + '\n', 5) + LOREM_IPSUM, initialCaretLine, initialCaretColumn, initialCaretOffset); //noinspection DuplicateExpressions,PointlessArithmeticExpression doTestCaretNotifications( editor.getContentComponent(), // step 1 new CaretAction(() -> rightWithSelection(), null), new CaretAction(() -> rightWithSelection(), null), // step 2 new CaretAction(() -> downWithSelection(), null), new CaretAction(() -> downWithSelection(), null), // step 3 new CaretAction(() -> rightWithSelection(), null), // step 4 new CaretAction(() -> downWithSelection(), null), // step 5 new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 1, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 2, initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 3, initialCaretOffset)), // step 6 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 3 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 3 - 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 7 new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 4 - 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 8 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 4 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 9 new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 5 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 6 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> leftWithSelection(), new CaretPos(initialCaretOffset - 7 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 10 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 7 - 4 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 7 - 5 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 11 new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 7 - 4 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 7 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 7 - 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 12 new CaretAction(() -> upWithSelection(), new CaretPos(initialCaretOffset - 7 - 3 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 13 new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 7 - 2 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset - 7 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 14 new CaretAction(() -> moveCaretToNextWordWithSelection(), new CaretPos(initialCaretOffset - 1 - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), new CaretAction(() -> rightWithSelection(), new CaretPos(initialCaretOffset - 1 * (LOREM_IPSUM.length() + 1), initialCaretOffset)), // step 15 new CaretAction(() -> downWithSelection(), new CaretPos(initialCaretOffset, initialCaretOffset)) ); }
testCaretNotificationsOfSelectionMovementsWithoutTextModificationsFromBottomRight
271,938
void () { // Similar to testCaretNotificationsWithinEmptyEditor: // any attempts to move the selection within an empty editor aren't supposed to cause caret movements => no caret updates are expected. final EditorImpl editor = initEditor("", 0, 0, 0); doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> leftWithSelection(), null), new CaretAction(() -> rightWithSelection(), null), new CaretAction(() -> moveCaretToPreviousWordWithSelection(), null), new CaretAction(() -> upWithSelection(), null), new CaretAction(() -> moveCaretToNextWordWithSelection(), null), new CaretAction(() -> downWithSelection(), null), new CaretAction(() -> leftWithSelection(), null), new CaretAction(() -> downWithSelection(), null), new CaretAction(() -> moveCaretToPreviousWordWithSelection(), null), new CaretAction(() -> rightWithSelection(), null), new CaretAction(() -> moveCaretToNextWordWithSelection(), null), new CaretAction(() -> upWithSelection(), null) ); }
testCaretNotificationsOfSelectionMovementsWithinEmptyEditor
271,939
void () { // Similar to testCaretNotificationsDuringTyping, but for multiple carets /* * caret #1 * v * (0th) |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ... * caret #5 * v * (2nd) Lorem ipsum dolor sit amet, consectetur adipisci|ng elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * ... * caret #4 * (primary) * v * (4th) Lorem ipsum dolor| sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret #2 * v * (5th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incidid|unt ut labore et dolore magna aliqua. * ... * caret #3 * v * (7th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.| */ final EditorImpl editor = initEditor( StringUtil.repeat(LOREM_IPSUM + '\n', 7) + LOREM_IPSUM, // caret #1 0, 0, 0 ); // caret #2 addCaret(editor, false, 5, 86, 5 * (LOREM_IPSUM.length() + 1) + 86); // caret #3 addCaret(editor, false, 7, LOREM_IPSUM.length(), 7 * (LOREM_IPSUM.length() + 1) + LOREM_IPSUM.length()); // caret #4 (primary) final int primaryCaretLine = 4; final int primaryCaretColumn = 17; final int primaryCaretInitialDot = primaryCaretLine * (LOREM_IPSUM.length() + 1) + primaryCaretColumn; addCaret(editor, true, primaryCaretLine, primaryCaretColumn, primaryCaretInitialDot); // caret #5 addCaret(editor, false, 2, 48, 2 * (LOREM_IPSUM.length() + 1) + 48); final int caretsBeforePrimaryCount = 2; // all notifications have to belong only to primary caret //noinspection PointlessArithmeticExpression doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> type('u'), new CaretPos( 1 * caretsBeforePrimaryCount + primaryCaretInitialDot + 1, 1 * caretsBeforePrimaryCount + primaryCaretInitialDot + 1)), new CaretAction(() -> type('n'), new CaretPos( 2 * caretsBeforePrimaryCount + primaryCaretInitialDot + 2, 2 * caretsBeforePrimaryCount + primaryCaretInitialDot + 2)), new CaretAction(() -> type('u'), new CaretPos( 3 * caretsBeforePrimaryCount + primaryCaretInitialDot + 3, 3 * caretsBeforePrimaryCount + primaryCaretInitialDot + 3)), new CaretAction(() -> type('s'), new CaretPos( 4 * caretsBeforePrimaryCount + primaryCaretInitialDot + 4, 4 * caretsBeforePrimaryCount + primaryCaretInitialDot + 4)), new CaretAction(() -> type(' '), new CaretPos( 5 * caretsBeforePrimaryCount + primaryCaretInitialDot + 5, 5 * caretsBeforePrimaryCount + primaryCaretInitialDot + 5)), new CaretAction(() -> type('d'), new CaretPos( 6 * caretsBeforePrimaryCount + primaryCaretInitialDot + 6, 6 * caretsBeforePrimaryCount + primaryCaretInitialDot + 6)), new CaretAction(() -> type('u'), new CaretPos( 7 * caretsBeforePrimaryCount + primaryCaretInitialDot + 7, 7 * caretsBeforePrimaryCount + primaryCaretInitialDot + 7)), new CaretAction(() -> type('o'), new CaretPos( 8 * caretsBeforePrimaryCount + primaryCaretInitialDot + 8, 8 * caretsBeforePrimaryCount + primaryCaretInitialDot + 8)), new CaretAction(() -> type(' '), new CaretPos( 9 * caretsBeforePrimaryCount + primaryCaretInitialDot + 9, 9 * caretsBeforePrimaryCount + primaryCaretInitialDot + 9)), new CaretAction(() -> type('t'), new CaretPos(10 * caretsBeforePrimaryCount + primaryCaretInitialDot + 10, 10 * caretsBeforePrimaryCount + primaryCaretInitialDot + 10)), new CaretAction(() -> type('r'), new CaretPos(11 * caretsBeforePrimaryCount + primaryCaretInitialDot + 11, 11 * caretsBeforePrimaryCount + primaryCaretInitialDot + 11)), new CaretAction(() -> type('e'), new CaretPos(12 * caretsBeforePrimaryCount + primaryCaretInitialDot + 12, 12 * caretsBeforePrimaryCount + primaryCaretInitialDot + 12)), new CaretAction(() -> type('s'), new CaretPos(13 * caretsBeforePrimaryCount + primaryCaretInitialDot + 13, 13 * caretsBeforePrimaryCount + primaryCaretInitialDot + 13)), new CaretAction(() -> type(' '), new CaretPos(14 * caretsBeforePrimaryCount + primaryCaretInitialDot + 14, 14 * caretsBeforePrimaryCount + primaryCaretInitialDot + 14)) ); }
testMultiCaretNotificationsDuringTyping
271,940
void () { /* * (0th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (1st) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret #1 * v * (2nd) Lorem ipsum dolor sit amet, conse|ctetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret #2 * (primary) * v * (3rd) Lorem ipsum dolor sit amet, consec|tetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * * caret #3 * v * (4th) Lorem ipsum dolor sit amet, consect|etur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (5th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. * (6th) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. */ final int primaryCaretLine = 3; final int primaryCaretColumn = 34; final int primaryCaretInitialDot = primaryCaretLine * (LOREM_IPSUM.length() + 1) + primaryCaretColumn; final EditorImpl editor = initEditor( StringUtil.repeat(LOREM_IPSUM + '\n', 6) + LOREM_IPSUM, // caret #1 primaryCaretLine - 1, primaryCaretColumn - 1, primaryCaretInitialDot - 1 - (LOREM_IPSUM.length() + 1) ); // caret #2 (primary) addCaret(editor, true, primaryCaretLine, primaryCaretColumn, primaryCaretInitialDot); // caret #3 addCaret(editor, false, primaryCaretLine + 1, primaryCaretColumn + 1, primaryCaretInitialDot + 1 + (LOREM_IPSUM.length() + 1)); //noinspection DuplicateExpressions doTestCaretNotifications( editor.getContentComponent(), new CaretAction(() -> leftWithSelection(), new CaretPos(primaryCaretInitialDot - 1, primaryCaretInitialDot)), new CaretAction(() -> rightWithSelection(), new CaretPos(primaryCaretInitialDot, primaryCaretInitialDot)), new CaretAction(() -> leftWithSelection(), new CaretPos(primaryCaretInitialDot - 1, primaryCaretInitialDot)), new CaretAction(() -> leftWithSelection(), new CaretPos(primaryCaretInitialDot - 2, primaryCaretInitialDot)), new CaretAction(() -> rightWithSelection(), new CaretPos(primaryCaretInitialDot - 1, primaryCaretInitialDot)), new CaretAction(() -> rightWithSelection(), new CaretPos(primaryCaretInitialDot, primaryCaretInitialDot)), new CaretAction(() -> rightWithSelection(), new CaretPos(primaryCaretInitialDot + 1, primaryCaretInitialDot)), new CaretAction(() -> rightWithSelection(), new CaretPos(primaryCaretInitialDot + 2, primaryCaretInitialDot)), new CaretAction(() -> leftWithSelection(), new CaretPos(primaryCaretInitialDot + 1, primaryCaretInitialDot)), new CaretAction(() -> leftWithSelection(), new CaretPos(primaryCaretInitialDot, primaryCaretInitialDot)) // Attempts to move the carets up or down cause carets hardly predictable merging, so let's skip them ); }
testMultiCaretNotificationsOfSelectionMovementsWithoutTextModifications
271,941
EditorImpl (@NotNull String text, int caretLineIndex, int caretColumnIndex, int expectedCaretPosition) { initText(text); final EditorImpl editor = (EditorImpl)getEditor(); editor.getCaretModel().getPrimaryCaret().moveToVisualPosition(new VisualPosition(caretLineIndex, caretColumnIndex)); assertEquals("unexpected position of dot of editor.getCaretModel().getPrimaryCaret()", expectedCaretPosition, editor.getCaretModel().getPrimaryCaret().getOffset()); // Initializing our custom a11y subsystem just to make sure that it doesn't break tests editor.getContentComponent().getAccessibleContext(); return editor; }
initEditor
271,942
Caret (@NotNull EditorImpl editor, boolean makePrimary, int caretLineIndex, int caretColumnIndex, int expectedCaretPosition) { final var result = editor.getCaretModel().addCaret(new VisualPosition(caretLineIndex, caretColumnIndex), makePrimary); assertNotNull("failed to add a caret", result); assertEquals("unexpected offset of an added caret", expectedCaretPosition, result.getOffset()); return result; }
addCaret
271,943
void (@NotNull JTextComponent editorComponent, CaretAction @NotNull ... caretActions) { /* * The implementation expects the following flow: * action.run() => caretUpdate() => returning control to the caller of action.run() */ final Ref<@Nullable CaretPos> caretUpdateNotification = new Ref<>(null); final int[] i = {0}; // a reference to a mutable int final CaretListener listener = (event) -> { assertNull("a new unexpected caretUpdateNotification at CaretAction #" + i[0] + ": " + caretUpdateNotification.get(), caretUpdateNotification.get()); caretUpdateNotification.set(new CaretPos(event.getDot(), event.getMark())); }; editorComponent.addCaretListener(listener); for (; i[0] < caretActions.length; ++i[0]) { caretActions[i[0]].action.run(); final var gotCaretUpdateNotification = caretUpdateNotification.get(); caretUpdateNotification.set(null); assertEquals("the wrong position(s) of the caret notification of CaretAction #" + i[0], caretActions[i[0]].caretUpdateNotification, gotCaretUpdateNotification); } editorComponent.removeCaretListener(listener); assertNull("a new unexpected caretUpdateNotification?", caretUpdateNotification.get()); }
doTestCaretNotifications
271,944
record (@NotNull Runnable action, @Nullable CaretPos caretUpdateNotification) {}
CaretAction
271,945
record (int dot, int mark) {}
CaretPos
271,946
void () { executeAction(IdeActions.ACTION_UNDO); }
undo
271,947
void () { initText("line1\nline2\n\n"); checkOverlapWithNormalRegion(0, 5, 1, 1, true); checkOverlapWithNormalRegion(12, 13, 1, 1, true); checkOverlapWithNormalRegion(6, 11, 1, 1, true); checkOverlapWithNormalRegion(6, 7, 1, 1, true); checkOverlapWithNormalRegion(10, 11, 1, 1, true); checkOverlapWithNormalRegion(7, 10, 1, 1, true); checkOverlapWithNormalRegion(5, 12, 1, 1, true); checkOverlapWithNormalRegion(5, 6, 1, 1, false); checkOverlapWithNormalRegion(5, 7, 1, 1, false); checkOverlapWithNormalRegion(5, 11, 1, 1, false); checkOverlapWithNormalRegion(6, 12, 1, 1, false); checkOverlapWithNormalRegion(10, 12, 1, 1, false); checkOverlapWithNormalRegion(11, 12, 1, 1, false); checkOverlapWithCustomRegion(1, 1, 1, 1, false); checkOverlapWithCustomRegion(1, 1, 0, 0, true); checkOverlapWithCustomRegion(1, 1, 0, 1, true); checkOverlapWithCustomRegion(1, 1, 1, 2, true); checkOverlapWithCustomRegion(1, 1, 0, 2, true); checkOverlapWithCustomRegion(1, 2, 0, 1, false); checkOverlapWithCustomRegion(1, 2, 2, 3, false); checkOverlapWithCustomRegion(1, 2, 1, 2, false); checkOverlapWithCustomRegion(1, 2, 1, 1, true); checkOverlapWithCustomRegion(1, 2, 0, 2, true); checkOverlapWithCustomRegion(1, 2, 1, 3, true); checkOverlapWithCustomRegion(1, 2, 0, 3, true); }
testAllowedOverlapping
271,948
void () { initText("line1\nline2\nline3\n"); addCustomFoldRegion(1, 2, 30); assertEquals(new VisualPosition(0, 2), getEditor().logicalToVisualPosition(new LogicalPosition(0, 2))); assertEquals(new VisualPosition(1, 0), getEditor().logicalToVisualPosition(new LogicalPosition(1, 2))); assertEquals(new VisualPosition(1, 0), getEditor().logicalToVisualPosition(new LogicalPosition(1, 10))); assertEquals(new VisualPosition(1, 0), getEditor().logicalToVisualPosition(new LogicalPosition(2, 2))); assertEquals(new VisualPosition(1, 0), getEditor().logicalToVisualPosition(new LogicalPosition(2, 10))); assertEquals(new VisualPosition(2, 2), getEditor().logicalToVisualPosition(new LogicalPosition(3, 2))); assertEquals(new LogicalPosition(0, 2), getEditor().visualToLogicalPosition(new VisualPosition(0, 2))); assertEquals(new LogicalPosition(1, 0), getEditor().visualToLogicalPosition(new VisualPosition(1, 0))); assertEquals(new LogicalPosition(1, 0), getEditor().visualToLogicalPosition(new VisualPosition(1, 1))); assertEquals(new LogicalPosition(1, 0), getEditor().visualToLogicalPosition(new VisualPosition(1, 2))); assertEquals(new LogicalPosition(3, 2), getEditor().visualToLogicalPosition(new VisualPosition(2, 2))); assertEquals(0, getEditor().offsetToVisualLine(5, false)); assertEquals(1, getEditor().offsetToVisualLine(6, false)); assertEquals(1, getEditor().offsetToVisualLine(11, false)); assertEquals(1, getEditor().offsetToVisualLine(12, false)); assertEquals(1, getEditor().offsetToVisualLine(17, false)); assertEquals(2, getEditor().offsetToVisualLine(18, false)); assertEquals(0, ((EditorImpl)getEditor()).visualLineStartOffset(0)); assertEquals(6, ((EditorImpl)getEditor()).visualLineStartOffset(1)); assertEquals(18, ((EditorImpl)getEditor()).visualLineStartOffset(2)); assertEquals(0, getEditor().visualLineToY(0)); assertEquals(12, getEditor().visualLineToY(1)); assertEquals(42, getEditor().visualLineToY(2)); assertEquals(54, getEditor().visualLineToY(3)); assertEquals(0, getEditor().yToVisualLine(0)); assertEquals(0, getEditor().yToVisualLine(11)); assertEquals(1, getEditor().yToVisualLine(12)); assertEquals(1, getEditor().yToVisualLine(13)); assertEquals(2, getEditor().yToVisualLine(42)); assertEquals(2, getEditor().yToVisualLine(53)); assertEquals(3, getEditor().yToVisualLine(54)); assertEquals(new Point(20, 0), getEditor().visualPositionToXY(new VisualPosition(0, 2))); assertEquals(new Point(0, 12), getEditor().visualPositionToXY(new VisualPosition(1, 0))); assertEquals(new Point(0, 12), getEditor().visualPositionToXY(new VisualPosition(1, 1))); assertEquals(new Point(0, 12), getEditor().visualPositionToXY(new VisualPosition(1, 2))); assertEquals(new Point(0, 42), getEditor().visualPositionToXY(new VisualPosition(2, 0))); assertEquals(new Point(20, 42), getEditor().visualPositionToXY(new VisualPosition(2, 2))); assertEquals(new VisualPosition(0, 0), getEditor().xyToVisualPosition(new Point(0, 0))); assertEquals(new VisualPosition(0, 2), getEditor().xyToVisualPosition(new Point(20, 11))); assertEquals(new VisualPosition(1, 0), getEditor().xyToVisualPosition(new Point(0, 12))); assertEquals(new VisualPosition(1, 0), getEditor().xyToVisualPosition(new Point(10, 13))); assertEquals(new VisualPosition(2, 0), getEditor().xyToVisualPosition(new Point(0, 42))); assertEquals(new VisualPosition(2, 2), getEditor().xyToVisualPosition(new Point(20, 53))); assertEquals(new Point(50, 0), getEditor().offsetToXY(5)); assertEquals(new Point(0, 12), getEditor().offsetToXY(6)); assertEquals(new Point(0, 12), getEditor().offsetToXY(11)); assertEquals(new Point(0, 12), getEditor().offsetToXY(17)); assertEquals(new Point(0, 42), getEditor().offsetToXY(18)); }
testCoordinateTransformations
271,949
void () { initText("line1\nline2\nline3\n"); getEditor().getSettings().setAdditionalLinesCount(0); getEditor().getSettings().setAdditionalColumnsCount(0); assertEquals(new Dimension(50, 48), getEditor().getContentComponent().getPreferredSize()); getEditor().getFoldingModel().runBatchFoldingOperation(() -> { assertNotNull(getEditor().getFoldingModel().addCustomLinesFolding(1, 2, new CustomFoldRegionRenderer() { @Override public int calcWidthInPixels(@NotNull CustomFoldRegion region) { return 75; } @Override public int calcHeightInPixels(@NotNull CustomFoldRegion region) { return 30; } @Override public void paint(@NotNull CustomFoldRegion region, @NotNull Graphics2D g, @NotNull Rectangle2D targetRegion, @NotNull TextAttributes textAttributes) {} })); }); assertEquals(new Dimension(75, 54), getEditor().getContentComponent().getPreferredSize()); }
testEditorSize
271,950
int (@NotNull CustomFoldRegion region) { return 75; }
calcWidthInPixels
271,951
int (@NotNull CustomFoldRegion region) { return 30; }
calcHeightInPixels
271,952
void (@NotNull CustomFoldRegion region, @NotNull Graphics2D g, @NotNull Rectangle2D targetRegion, @NotNull TextAttributes textAttributes) {}
paint
271,953
void () { initText("<caret>line1\nline2\nline3\n "); addCustomFoldRegion(1, 2, 2); assertEquals(new VisualPosition(0, 0), getEditor().getCaretModel().getVisualPosition()); right(); right(); right(); right(); right(); assertEquals(new VisualPosition(0, 5), getEditor().getCaretModel().getVisualPosition()); right(); assertEquals(new VisualPosition(1, 0), getEditor().getCaretModel().getVisualPosition()); right(); assertEquals(new VisualPosition(2, 0), getEditor().getCaretModel().getVisualPosition()); right(); assertEquals(new VisualPosition(2, 1), getEditor().getCaretModel().getVisualPosition()); left(); left(); assertEquals(new VisualPosition(1, 0), getEditor().getCaretModel().getVisualPosition()); left(); assertEquals(new VisualPosition(0, 5), getEditor().getCaretModel().getVisualPosition()); left(); assertEquals(new VisualPosition(0, 4), getEditor().getCaretModel().getVisualPosition()); down(); assertEquals(new VisualPosition(1, 0), getEditor().getCaretModel().getVisualPosition()); down(); assertEquals(new VisualPosition(2, 1), getEditor().getCaretModel().getVisualPosition()); up(); assertEquals(new VisualPosition(1, 0), getEditor().getCaretModel().getVisualPosition()); up(); assertEquals(new VisualPosition(0, 4), getEditor().getCaretModel().getVisualPosition()); }
testCaretMovement
271,954
void () { initText("text"); getEditor().getSettings().setAdditionalLinesCount(0); getEditor().getSettings().setAdditionalColumnsCount(0); FoldingModel foldingModel = getEditor().getFoldingModel(); int[] size = new int[] {35, 25}; CustomFoldRegion[] region = new CustomFoldRegion[1]; foldingModel.runBatchFoldingOperation(() -> { region[0] = foldingModel.addCustomLinesFolding(0, 0, new CustomFoldRegionRenderer() { @Override public int calcWidthInPixels(@NotNull CustomFoldRegion region) { return size[0]; } @Override public int calcHeightInPixels(@NotNull CustomFoldRegion region) { return size[1]; } @Override public void paint(@NotNull CustomFoldRegion region, @NotNull Graphics2D g, @NotNull Rectangle2D targetRegion, @NotNull TextAttributes textAttributes) {} }); assertNotNull(region[0]); }); assertEquals(25, getEditor().visualLineToY(1)); assertEquals(new Dimension(35, 25), getEditor().getContentComponent().getPreferredSize()); size[0] = 36; size[1] = 26; region[0].update(); assertEquals(26, getEditor().visualLineToY(1)); assertEquals(new Dimension(36, 26), getEditor().getContentComponent().getPreferredSize()); }
testSizeUpdate
271,955
int (@NotNull CustomFoldRegion region) { return size[0]; }
calcWidthInPixels
271,956
int (@NotNull CustomFoldRegion region) { return size[1]; }
calcHeightInPixels
271,957
void (@NotNull CustomFoldRegion region, @NotNull Graphics2D g, @NotNull Rectangle2D targetRegion, @NotNull TextAttributes textAttributes) {}
paint
271,958
void () { initText("line1\nline2\nline3"); FoldingModelEx model = (FoldingModelEx)getEditor().getFoldingModel(); AtomicInteger invocationCount = new AtomicInteger(); model.addListener(new FoldingListener() { @Override public void beforeFoldRegionDisposed(@NotNull FoldRegion region) { invocationCount.incrementAndGet(); } }, getTestRootDisposable()); FoldRegion region = addFoldRegion(0, 17, "."); assertNotNull(region); assertTrue(region.isValid()); CustomFoldRegion customRegion = addCustomFoldRegion(1, 1); assertNotNull(customRegion); assertTrue(customRegion.isValid()); assertEquals(0, invocationCount.get()); runWriteCommand(() -> getEditor().getDocument().deleteString(11, 17)); assertTrue(region.isValid()); assertFalse(customRegion.isValid()); assertEquals(1, invocationCount.get()); }
testInvalidationDueToRelationToAnotherFoldRegion
271,959
void (@NotNull FoldRegion region) { invocationCount.incrementAndGet(); }
beforeFoldRegionDisposed
271,960
void () { initText("text"); getEditor().getSettings().setAdditionalLinesCount(0); getEditor().getSettings().setAdditionalColumnsCount(0); addInlay(4, 15); addCustomFoldRegion(0, 0, 40, 30); assertEquals(new Dimension(40, 30), getEditor().getContentComponent().getPreferredSize()); }
testInlineInlayAtLineEndDoesNotHaveImpact
271,961
void () { initText("line1\n<caret>line2\nline3"); assertNotNull(addCustomFoldRegion(1, 1)); delete(); checkResultByText("line1\n<caret>\nline3"); }
testDelete
271,962
void () { initText("line1\nline2\n<caret>\nline4"); assertNotNull(addCustomFoldRegion(1, 1)); backspace(); checkResultByText("line1\n<caret>\nline4"); }
testBackspace
271,963
void () { initText("text"); assertNotNull(addCustomFoldRegion(0, 0, 321, 123)); List<Boolean> results = new ArrayList<>(); getEditor().addEditorMouseMotionListener(new EditorMouseMotionListener() { @Override public void mouseMoved(@NotNull EditorMouseEvent e) { results.add(e.isOverText()); } }); mouse().moveToXY(400, 100); assertEquals(List.of(Boolean.FALSE), results); }
testOverText
271,964
void (@NotNull EditorMouseEvent e) { results.add(e.isOverText()); }
mouseMoved
271,965
void () { initText("line1\nline2"); assertNotNull(addCustomFoldRegion(0, 0)); assertNotNull(addCollapsedFoldRegion(6, 11, "...")); runWriteCommand(() -> getEditor().getDocument().deleteString(5, 6)); verifyFoldingState("[FoldRegion +(5:10), placeholder='...']"); }
testOverlappingAfterDocumentChange
271,966
void () { initText(""); ((DocumentImpl)getEditor().getDocument()).setAcceptSlashR(true); runWriteCommand(() -> getEditor().getDocument().insertString(0, "a\rb\nc")); assertNotNull(addCustomFoldRegion(0, 0)); addCollapsedFoldRegion(3, 5, "..."); runWriteCommand(() -> getEditor().getDocument().deleteString(2, 3)); verifyFoldingState("[FoldRegion +(1:4), placeholder='...']"); }
testOverlappingAfterDocumentChangeComplexLineBreaks
271,967
void (int regionStartOffset, int regionEndOffset, int customRegionStartLine, int customRegionEndLine, boolean allowed) { try { assertNotNull(addFoldRegion(regionStartOffset, regionEndOffset, ".")); CustomFoldRegion customRegion = addCustomFoldRegion(customRegionStartLine, customRegionEndLine); assertEquals(allowed, customRegion != null); } finally { // cleanup FoldingModelEx model = (FoldingModelEx)getEditor().getFoldingModel(); model.runBatchFoldingOperation(() -> model.clearFoldRegions()); } }
checkOverlapWithNormalRegion
271,968
void (int customRegionStartLine1, int customRegionEndLine1, int customRegionStartLine2, int customRegionEndLine2, boolean allowed) { try { assertNotNull(addCustomFoldRegion(customRegionStartLine1, customRegionEndLine1)); CustomFoldRegion customRegion2 = addCustomFoldRegion(customRegionStartLine2, customRegionEndLine2); assertEquals(allowed, customRegion2 != null); } finally { // cleanup FoldingModelEx model = (FoldingModelEx)getEditor().getFoldingModel(); model.runBatchFoldingOperation(() -> model.clearFoldRegions()); } }
checkOverlapWithCustomRegion
271,969
EditorView (@NotNull Editor editor) { return ((EditorImpl)editor).myView; }
getView
271,970
void (String text) { prepare(text, PlainTextFileType.INSTANCE); }
prepareText
271,971
void (String text, FileType fileType) { init(text.replace(RTL_CHAR_REPRESENTATION, RTL_CHAR), fileType); }
prepare
271,972
void (String text) { checkResultByText(text.replace(RTL_CHAR_REPRESENTATION, RTL_CHAR)); }
checkResult
271,973
void (int offset, LogicalPosition logicalPosition, VisualPosition visualPositionTowardsSmallerOffsets, VisualPosition visualPositionTowardsLargerOffsets, Point xy) { checkOffsetConversions(offset, logicalPosition, visualPositionTowardsSmallerOffsets, visualPositionTowardsLargerOffsets, xy, xy); }
checkOffsetConversions
271,974
void (int offset, LogicalPosition logicalPosition, VisualPosition visualPositionTowardsSmallerOffsets, VisualPosition visualPositionTowardsLargerOffsets, Point xyTowardsSmallerOffsets, Point xyTowardsLargerOffsets) { assertLogicalPositionsEqual("Wrong offset->logicalPosition calculation", logicalPosition, getEditor().offsetToLogicalPosition(offset)); assertVisualPositionsEqual("Wrong beforeOffset->visualPosition calculation", visualPositionTowardsSmallerOffsets, getEditor().offsetToVisualPosition(offset, false, false)); assertVisualPositionsEqual("Wrong afterOffset->visualPosition calculation", visualPositionTowardsLargerOffsets, getEditor().offsetToVisualPosition(offset, true, false)); assertEquals("Wrong afterOffset->visualLine calculation", visualPositionTowardsLargerOffsets.line, ((EditorImpl)getEditor()).offsetToVisualLine(offset)); assertEquals("Wrong beforeOffset->xy calculation", xyTowardsSmallerOffsets, getEditor().offsetToXY(offset, false, false)); assertEquals("Wrong afterOffset->xy calculation", xyTowardsLargerOffsets, getEditor().offsetToXY(offset, true, false)); }
checkOffsetConversions
271,975
void (int logicalColumn, int offset, VisualPosition visualPositionForPrecedingLp, VisualPosition visualPositionForSucceedingLp) { checkLPConversions(lB(logicalColumn), offset, visualPositionForPrecedingLp); checkLPConversions(lF(logicalColumn), offset, visualPositionForSucceedingLp); }
checkLPConversions
271,976
void (LogicalPosition logicalPosition, int offset, VisualPosition visualPosition) { assertEquals("Wrong logicalPosition->offset calculation", offset, getEditor().logicalPositionToOffset(logicalPosition)); assertVisualPositionsEqual("Wrong logicalPosition->visualPosition calculation", visualPosition, getEditor().logicalToVisualPosition(logicalPosition)); }
checkLPConversions
271,977
void (int visualColumn, LogicalPosition logicalPositionForLeftLeaningVp, LogicalPosition logicalPositionForRightLeaningVp, Point xy) { checkVPConversions(vL(visualColumn), logicalPositionForLeftLeaningVp, xy); checkVPConversions(vR(visualColumn), logicalPositionForRightLeaningVp, xy); }
checkVPConversions
271,978
void (VisualPosition visualPosition, LogicalPosition logicalPosition, Point xy) { assertLogicalPositionsEqual("Wrong visualPosition->logicalPosition calculation", logicalPosition, getEditor().visualToLogicalPosition(visualPosition)); assertEquals("Wrong visualPosition->xy calculation", xy, getEditor().visualPositionToXY(visualPosition)); }
checkVPConversions
271,979
void (Point xy, VisualPosition visualPosition) { assertVisualPositionsEqual("Wrong xy->visualPosition calculation", visualPosition, getEditor().xyToVisualPosition(xy)); }
checkXYConversion
271,980
void (String message, LogicalPosition expectedPosition, LogicalPosition actualPosition) { assertEquals(message, expectedPosition, actualPosition); assertEquals(message + " (direction flag)", expectedPosition.leansForward, actualPosition.leansForward); }
assertLogicalPositionsEqual
271,981
void (String message, VisualPosition expectedPosition, VisualPosition actualPosition) { assertEquals(message, expectedPosition, actualPosition); assertEquals(message + " (direction flag)", expectedPosition.leansRight, actualPosition.leansRight); }
assertVisualPositionsEqual
271,982
void (VisualPosition visualPosition) { assertVisualPositionsEqual("Wrong caret position", visualPosition, getEditor().getCaretModel().getVisualPosition()); }
assertCaretPosition
271,983
void (int visualColumn, boolean reversedDirection) { assertVisualCaretLocation(0, visualColumn, reversedDirection); }
assertVisualCaretLocation
271,984
void (int visualLine, int visualColumn, boolean reversedDirection) { assertEquals(1, getEditor().getCaretModel().getCaretCount()); Caret caret = getEditor().getCaretModel().getPrimaryCaret(); assertEquals(visualLine, caret.getVisualPosition().line); assertEquals(visualColumn, caret.getVisualPosition().column); assertEquals(reversedDirection, caret.isAtRtlLocation()); }
assertVisualCaretLocation
271,985
void (String textWithBoundaryMarkers, String fileExtension) { java.util.List<Integer> expectedBoundaryPositions = new ArrayList<>(); StringBuilder rawTextBuilder = new StringBuilder(); for (int i = 0; i < textWithBoundaryMarkers.length(); i++) { char c = textWithBoundaryMarkers.charAt(i); if (c == BIDI_BOUNDARY_MARKER) { expectedBoundaryPositions.add(rawTextBuilder.length()); } else { rawTextBuilder.append(c); } } String rawText = rawTextBuilder.toString(); configureFromFileText(getTestName(false) + "." + fileExtension, rawText.replace(RTL_CHAR_REPRESENTATION, RTL_CHAR)); java.util.List<Integer> actualBoundaryPositions = new ArrayList<>(); for (int i = 1; i < rawText.length(); i++) { if (!getEditor().offsetToVisualPosition(i, false, false).equals( getEditor().offsetToVisualPosition(i, true, false))) { actualBoundaryPositions.add(i); } } assertEquals("Unexpected bidi regions boundaries' positions", expectedBoundaryPositions, actualBoundaryPositions); }
checkBidiRunBoundaries
271,986
LogicalPosition (int column) { return new LogicalPosition(0, column); }
lB
271,987
LogicalPosition (int line, int column) { return new LogicalPosition(line, column); }
lB
271,988
LogicalPosition (int column) { return new LogicalPosition(0, column, true); }
lF
271,989
LogicalPosition (int line, int column) { return new LogicalPosition(line, column, true); }
lF
271,990
VisualPosition (int column) { return new VisualPosition(0, column); }
vL
271,991
VisualPosition (int line, int column) { return new VisualPosition(line, column); }
vL
271,992
VisualPosition (int column) { return new VisualPosition(0, column, true); }
vR
271,993
VisualPosition (int line, int column) { return new VisualPosition(line, column, true); }
vR
271,994
Point (int x) { return new Point(x, 0); }
xy
271,995
Point (int x, int y) { return new Point(x, y); }
xy
271,996
int (int h) { return (int)(FontPreferences.DEFAULT_LINE_SPACING * h); }
ls
271,997
Component () { return myFocusOwner; }
getFocusOwner
271,998
BufferedImage (BufferedImage image) { //noinspection UndesirableClassUsage return new BufferedImage(image.getColorModel(), image.copyData(null), image.getColorModel().isAlphaPremultiplied(), null); }
copy
271,999
void (String text) { init(text, PlainTextFileType.INSTANCE); getEditor().getSettings().setAdditionalLinesCount(0); getEditor().getSettings().setAdditionalColumnsCount(3); getEditor().getSettings().setCaretRowShown(false); }
init