<commit_before>package org.fxmisc.richtext.api;

import javafx.stage.Stage;
import org.fxmisc.richtext.Caret;
import org.fxmisc.richtext.InlineCssTextAreaAppTest;
import org.junit.Test;
import org.testfx.util.WaitForAsyncUtils;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class CaretTests extends InlineCssTextAreaAppTest {

    private static final String MANY_PARS_OF_TEXT;

    static {
        int totalLines = 20;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < totalLines; i++) {
            sb.append(i).append("\n");
        }
        sb.append(totalLines);
        MANY_PARS_OF_TEXT = sb.toString();
    }

    @Override
    public void start(Stage stage) throws Exception {
        super.start(stage);

        // insure caret is always visible
        area.setShowCaret(Caret.CaretVisibility.ON);
        area.replaceText(MANY_PARS_OF_TEXT);
        area.moveTo(0);
        area.showParagraphAtTop(0);
    }

    @Test
    public void caret_bounds_are_present_after_moving_caret_and_following_it() {
        assertTrue(area.getCaretBounds().isPresent());

        // move caret outside of viewport
        area.moveTo(area.getLength());
        area.requestFollowCaret();

        // needed for test to pass
        WaitForAsyncUtils.waitForFxEvents();

        // viewport should update itself so caret is visible again
        assertTrue(area.getCaretBounds().isPresent());<commit_msg>Reduce stage height to display ~3 lines<commit_after>package org.fxmisc.richtext.api;

import javafx.stage.Stage;
import org.fxmisc.richtext.Caret;
import org.fxmisc.richtext.InlineCssTextAreaAppTest;
import org.junit.Test;
import org.testfx.util.WaitForAsyncUtils;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class CaretTests extends InlineCssTextAreaAppTest {

    private static final String MANY_PARS_OF_TEXT;

    static {
        int totalLines = 20;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < totalLines; i++) {
            sb.append(i).append("\n");
        }
        sb.append(totalLines);
        MANY_PARS_OF_TEXT = sb.toString();
    }

    @Override
    public void start(Stage stage) throws Exception {
        super.start(stage);
        stage.setHeight(50);

        // insure caret is always visible
        area.setShowCaret(Caret.CaretVisibility.ON);
        area.replaceText(MANY_PARS_OF_TEXT);
        area.moveTo(0);
        area.showParagraphAtTop(0);
    }

    @Test
    public void caret_bounds_are_present_after_moving_caret_and_following_it() {
        assertTrue(area.getCaretBounds().isPresent());

        // move caret outside of viewport
        area.moveTo(area.getLength());
        area.requestFollowCaret();

        // needed for test to pass
        WaitForAsyncUtils.waitForFxEvents();

        // viewport should update itself so caret is visible again
        assertTrue(area.getCaretBounds().isPresent());
{'fraction_non_alphanumeric': 0.09730986383261375, 'fraction_numerical': 0.004317502490866822, 'mean_word_length': 2.947575360419397, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '681585', 'n_tokens_mistral': 921, 'n_tokens_neox': 891, 'n_words': 190}