Describe the bug
With the new find and replace functionality, an out-of-bounds error can be encountered. This is the case when the find string is replaced (without deleting is first) with a new string that result in a lower number of matches than the original prompt.
Example of a search and replace with a high number of matches:
Then I search something specific with lower matches:
Now replacing a single instance results in the out-of-bounds error.
To Reproduce
Steps to reproduce the behavior:
Open the cruise control example model cruise.xml.
Open the global replacement window.
Type a in Find. This should result in 163 matches.
Go to a high number math with the up arrow, for example match 157, so you see 157/163.
Highlight a in the Find box and replace it with intwithout using backspace / delete to remove the a first. This should result in 13 matched.
Now observe that it stil 'highlights' the 157th selection with 157/13.
Type something in Replace, like double.
Click Replace to get the error message.
Expected behavior
The highlight counter should also change when the Find input is changed without backspace or delete. This would probably resolve the out of bounds error.
Version(s) of UPPAAL tested
UPPAAL Stratego 10 beta 13.
Desktop (please complete the following information):
Version UPPAAL 4.1.20-stratego-10-beta13 (rev. 772014A1367888DD), September 2022
OS, Java version: MacOS 12.6
Additional context
The full exception trace.
java.lang.IndexOutOfBoundsException: Index 156 out of bounds for length 13
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.base/java.util.Objects.checkIndex(Objects.java:359)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at eE.a(Unknown Source)
at eH.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2313)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6626)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3389)
at java.desktop/java.awt.Component.processEvent(Component.java:6391)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5001)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4833)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:746)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:744)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:743)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Describe the bug With the new find and replace functionality, an out-of-bounds error can be encountered. This is the case when the find string is replaced (without deleting is first) with a new string that result in a lower number of matches than the original prompt.
Example of a search and replace with a high number of matches:
Then I search something specific with lower matches:
Now replacing a single instance results in the out-of-bounds error.
To Reproduce Steps to reproduce the behavior:
cruise.xml
.a
inFind
. This should result in 163 matches.157/163
.a
in theFind
box and replace it withint
without using backspace / delete to remove thea
first. This should result in 13 matched.157/13
.Replace
, likedouble
.Replace
to get the error message.Expected behavior The highlight counter should also change when the
Find
input is changed without backspace or delete. This would probably resolve the out of bounds error.Version(s) of UPPAAL tested UPPAAL Stratego 10 beta 13.
Desktop (please complete the following information):
Additional context The full exception trace.