mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-251582 IJPL-247496 [editor, markdown] add EditorCharacterGridSizeTest
Partial cherry-pick of new tests for grid mode to resolve conflicts when cherry-picking tests for IJPL-247496 IJ-CR-217736 (cherry picked from commit 870d075ff879d5619e2c596784a4b726e354ce7a) GitOrigin-RevId: 5336f4aff35c14ed1aa77bc1f3c98ddb881724c3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2889a3ade4
commit
12e50374c4
+40
@@ -0,0 +1,40 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
|
||||
public class EditorCharacterGridSizeTest extends AbstractEditorTest {
|
||||
private static final String LONG_LINE = "x".repeat(200);
|
||||
private static final int CONTENT_WIDTH = LONG_LINE.length() * TEST_CHAR_WIDTH;
|
||||
|
||||
private void enableGridMode() {
|
||||
getEditor().getSettings().setCharacterGridWidthMultiplier(1.0f);
|
||||
((EditorEx)getEditor()).reinitSettings();
|
||||
assertNotNull(((EditorImpl)getEditor()).getCharacterGrid());
|
||||
}
|
||||
|
||||
private int preferredWidth() {
|
||||
return getEditor().getContentComponent().getPreferredSize().width;
|
||||
}
|
||||
|
||||
// IJPL-247496: non-wrapping grid editors (Markdown) must expose the full line width, not the viewport.
|
||||
public void testNonWrappingGridEditorIsScrollableToTheEndOfLongLines() {
|
||||
initText(LONG_LINE);
|
||||
getEditor().getSettings().setAdditionalColumnsCount(0);
|
||||
setEditorVisibleSize(20, 10);
|
||||
enableGridMode();
|
||||
|
||||
assertTrue(getEditor().getScrollingModel().getVisibleArea().width < CONTENT_WIDTH);
|
||||
assertTrue("preferred=" + preferredWidth(), preferredWidth() >= CONTENT_WIDTH);
|
||||
}
|
||||
|
||||
// IJPL-180831: soft-wrapping grid editors (terminal) still clamp preferred width to the viewport.
|
||||
public void testWrappingGridEditorStaysClampedToViewport() {
|
||||
initText(LONG_LINE);
|
||||
getEditor().getSettings().setAdditionalColumnsCount(0);
|
||||
configureSoftWraps(20);
|
||||
enableGridMode();
|
||||
|
||||
assertTrue("preferred=" + preferredWidth(), preferredWidth() < CONTENT_WIDTH);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user