<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
        {font-family:"Iosevka Fixed SS16";
        panose-1:2 0 5 9 3 0 0 0 0 4;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Iosevka Fixed SS16";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Thank you, Pavel, for filing the ticket (it will take some time before it gets routed to me).  And thank you so much for the feedback - keep it going!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of PavelTurk <pavelturk2000@gmail.com><br>
<b>Date: </b>Wednesday, April 30, 2025 at 08:54<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Re: CodeArea: too frequent model updates<o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt">Hello, Andy<br>
<br>
I've made sure to formulate everything very precisely and just created a new issue. Unfortunately I know only its ID: 9078451.<br>
<br>
If my proposal is incorrect - then this issue is not meant to be resolved. However, I'm certain this is an important question regardless.<br>
<br>
Best regards, Pavel<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">On 4/30/25 17:45, Andy Goryachev wrote:<o:p></o:p></span></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Dear Pavel:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">As I mentioned before, the view might request more paragraphs than currently visible, so it works as designed.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">When you say it's slow, could you tell what metric / measurement you used?  The attached code does not appear slow on my macOS.  Would you provide a reproducer which can illustrate
 the issue?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Thanks</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <a href="mailto:openjfx-dev-retn@openjdk.org">
<openjfx-dev-retn@openjdk.org></a> on behalf of PavelTurk <a href="mailto:pavelturk2000@gmail.com">
<pavelturk2000@gmail.com></a><br>
<b>Date: </b>Wednesday, April 30, 2025 at 04:14<br>
<b>To: </b><a href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a> <a href="mailto:openjfx-dev@openjdk.org">
<openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>CodeArea: too frequent model updates</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">Trying to understand why my Jfx CodeArea works so slowly I wrote a test application (see below).<br>
And I got interesting results. If you start the application you will see that about 10 paragraphs<br>
are visible.<br>
<br>
1. If after start you click on the report button you will see that about 113 paragraphs were created (remember 10 visible).<br>
2. If you click event button (as I understand to update only 15 paragraphs - I can be wrong here) in the report you will see 112 paragraphs.<br>
3. If you scroll to line 100, click report to clear, add one letter via keyboard and in the new report you will see 210 paragraphs were updated.<br>
So, with one paragraph modified and 10 paragraphs visible CodeArea updates 210 paragraphs.<br>
<br>
I see two solutions here:<br>
1) If Jfx CodeArea wants to update paragraphs itself it should be optimized<br>
2) A better solution is to remove final modifier from CodeTextModel.getParagraph(int index) method so that we could override it.<br>
<br>
public class JfxTextArea extends Application {<br>
<br>
     @Override<br>
     public void start(Stage primaryStage) throws Exception {<br>
         CodeArea codeArea = new CodeArea();<br>
         codeArea.setLineNumbersEnabled(true);<br>
         final List<Integer> requestedIndexes = new ArrayList<>();<br>
         codeArea.setSyntaxDecorator(new SyntaxDecorator() {<br>
             @Override<br>
             public RichParagraph createRichParagraph(CodeTextModel ctm, int i) {<br>
                 requestedIndexes.add(i);<br>
                 RichParagraph.Builder b = RichParagraph.builder();<br>
                 b.addSegment(ctm.getPlainText(i));<br>
                 return b.build();<br>
             }<br>
<br>
             @Override<br>
             public void handleChange(CodeTextModel ctm, TextPos tp, TextPos tp1, int i, int i1, int i2) {<br>
<br>
             }<br>
         });<br>
         StringBuilder sb = new StringBuilder();<br>
         for (var i = 0; i < 1000; i++) {<br>
             sb.append(i);<br>
             sb.append("\n");<br>
         }<br>
         codeArea.setText(sb.toString());<br>
<br>
         var reportButton = new Button("Report & Clear");<br>
         reportButton.setOnAction(e -> {<br>
             Collections.sort(requestedIndexes);<br>
             System.out.println("Created/Updated " + requestedIndexes.size() + " paragraphs: " + requestedIndexes);<br>
             requestedIndexes.clear();<br>
         });<br>
         var topButton = new Button("To Top");<br>
         topButton.setOnAction(e -> codeArea.select(new TextPos(0, 0, 0, true)));<br>
         var bottomButton = new Button("To Bottom");<br>
         bottomButton.setOnAction(e -> codeArea.select(new TextPos(999, 0, 0, true)));<br>
         var eventButton = new Button("Fire Event");<br>
         eventButton.setOnAction(e -> codeArea.getModel()<br>
                 .fireStyleChangeEvent(new TextPos(0, 0, 0, true), new TextPos(15, 0, 0, true)));<br>
         HBox buttonBox = new HBox(reportButton, topButton, bottomButton, eventButton);<br>
<br>
         VBox.setVgrow(codeArea, Priority.ALWAYS);<br>
         VBox root = new VBox(codeArea, buttonBox);<br>
         Scene scene = new Scene(root, 600, 200);<br>
         primaryStage.setScene(scene);<br>
         primaryStage.show();<br>
<br>
     }<br>
<br>
     public static void main(String[] args) {<br>
         launch(args);<br>
     }<br>
<br>
}<br>
<br>
Best regards, Pavel</span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>