duderstadt-lab / mars-fx

BSD 2-Clause "Simplified" License
3 stars 1 forks source link

IndexOutOfBounds Error KCP command #44

Closed NadiaHuisjes closed 3 years ago

NadiaHuisjes commented 3 years ago

Hi Karl! I got a new error message. I ran the KCP tool a couple of times and stumbled upon the following IndexOutOfBounds error. Running the KCP command again with different settings prompted the same error. The command had worked before with exactly these settings on the same archive so I have the feeling this emerges when run a couple of times.

Screenshot 2021-06-24 at 16 40 21 Screenshot 2021-06-24 at 16 41 15 Screenshot 2021-06-24 at 16 40 38 Screenshot 2021-06-24 at 16 40 29 Screenshot 2021-06-24 at 16 40 25
karlduderstadt commented 3 years ago

This error is thrown when the archive unlocks after KCP is done and attempts to update the log. Essentially the method replaceText is called on the MarkdownTextArea and contains the log. This method should then call replace with a range 0 to getLength() and the entire log of the metadata record with the new text at the end (log message from recent KCP run).

Somehow it seems the range is not valid when this is done. This could be because somehow getLength() is not correct. So in the end this is entirely a UI issue and there appear to be do problem with KCP itself. In fact, I would expect other commands to also trigger this issue when updating the log.

I will attempt to fix this by directly calling replaceText(start, end, text) with a range. Calling replaceText(text) is actually calling an override version of the method in MarkdownTextArea that also attempt to properly manage the scrollbar to the correction position. Directly calling replaceText with the range should avoid this extra steps that might be triggering the error.

The only way yo replace the entire contexts of the TextArea is by calling replaceText there is no direct setText option as far as I can tell.

karlduderstadt commented 3 years ago

Just out of curiosity, @NadiaHuisjes did you have some search text entered in the log panel when this happened?

karlduderstadt commented 3 years ago

Ok, I don't think this is the fix. I just got the same error message again. I will keep investigating. Looks like this error is triggered when you have the log Pane open and you run KCP. I am not getting it every time

karlduderstadt commented 3 years ago

This error actually comes from reactfx, which is a project that richtextfx depends on. It is hard to understand what is causing this. The IndexOutOfBounds is not from the range of text added in the log message. it is a range for some other visual element.

In any case, simply clearing the textarea and then replacing the text with the update log appears to fix the problem in my tests.