Bug #74699 Replace & Find inserting one replace-string at cursor if nothing is selected
Submitted: 5 Nov 2014 14:06 Modified: 23 Jan 2015 1:53
Reporter: Johannes Taxacher Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:6.2.3 OS:Any
Assigned to: CPU Architecture:Any

[5 Nov 2014 14:06] Johannes Taxacher
Description:
When clicking the "replace & find" button in SQL editor while nothing is selected, one replace-string is inserted at current cursor position before editor highlights the next match. If text happens to be selected, that doesn't match the "find" string it is still replaced with he replace-string.

How to repeat:
1. copy this into SQL editor: SELECT LEFT('foobar', locate('b', 'foobar')-1);
2. make sure no text is selected in the editor after pasting/entering
3. hit ctrl+F (or choose find fom edit menu)
4. switch to "Find & Replace" in dropdown on find toolbar
5. enter 'foo' into find inputbox and 'bar' into the replace inputbox
6. pay attention to the curent cursor position in the SQL text editor and click "replace & find" button
observe that 'bar' was inserted here the cursor was positioned before the first found instance of 'foo' was highlighted

if you modify step #2 so that instead of selecting nothing, make the word LEFT selected in text editor, after step #6 'LEFT' will be replaced with 'bar' (also not desired behavior)

Suggested fix:
- if nothing is selected, dont insert a replace-term before highlighting the first search string
- if something is selected that doesn't match the search term, also dont replace it, just move to highlighting the first find
[23 Jan 2015 1:53] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Workbench 6.2.5 / 6.3.0 releases, and here's the changelog entry:

When clicking the "Replace and Find" button in the SQL editor without
selected text, a replace-string was inserted at the current cursor
position before the editor highlighted the next match. If instead text was
selected, the selected text was also replaced with the replace-string even
if it did not match the found-string. 

Now, selected text does not affect the "Replace and Find" functionality. 

Thank you for the bug report.