awecz / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

find and replace doesn't use a literal replacement in non-reg exp mode #165

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. enter text '//// comment'
2. open find and replace dialog
3. find string '//'
4. replace string '\'
5. click 'replace all'

What is the expected output? What do you see instead?

expected: string '\\ comment' in editor pane.
actual:

Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException
: String index out of range: 1
        at java.lang.String.charAt(Unknown Source)
        at java.util.regex.Matcher.appendReplacement(Unknown Source)
        at java.util.regex.Matcher.replaceAll(Unknown Source)
        at jsyntaxpane.actions.DocumentSearchData.doReplaceAll(DocumentSearchData.java:133)
        at jsyntaxpane.actions.gui.ReplaceDialog.jBtnReplaceAllActionPerformed(ReplaceDialog.java:251)
        at jsyntaxpane.actions.gui.ReplaceDialog.access$200(ReplaceDialog.java:3
4)
        at jsyntaxpane.actions.gui.ReplaceDialog$3.actionPerformed(ReplaceDialog.java:141)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)

Solution is probably to call Matcher.quoteReplacement() on the replace string.

What version of the product are you using? On what operating system?
jsyntaxpane-0.9.5-b29.jar
win xp64

Original issue reported on code.google.com by javlo...@gmail.com on 18 Oct 2010 at 10:19

GoogleCodeExporter commented 8 years ago
Fix coming in shortly.

Original comment by ayman.al...@gmail.com on 8 Nov 2010 at 5:59

GoogleCodeExporter commented 8 years ago
Fixed in source r146

Original comment by ayman.al...@gmail.com on 8 Nov 2010 at 6:06