Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: ashotisatoshi on May 27, 2017, 05:42:46 pm

Title: Could this be a bug ?
Post by: ashotisatoshi on May 27, 2017, 05:42:46 pm

Situation:

I'm doing a 'Replace' of my code for example
Search for 'foo' replace with 'bar'
and hit alt_r
As code::blocks finds each 'foo' I either hit 'Y' or 'N';

Problem:
If I hold down the 'Y' for a particular section of code which I know
all needs to be replaced, sometimes code::blocks (editor) treats the
'Y' as not a 'YES' but as me typing in the letter y into the code,
thus having the letter 'Y' mixed into my code..

Title: Re: Could this be a bug ?
Post by: oBFusCATed on May 27, 2017, 08:01:42 pm
Are you sure the keyboard focus is on the dialog (yes, no, all, cancel) and not on the editor?
Title: Re: Could this be a bug ?
Post by: ashotisatoshi on May 28, 2017, 12:42:17 am

I guess that's the problem,

If I dont hold down the 'Y' key, rather tap it quickly it will replace correctly,
only when I hold it down the editor incorrectly directs the key press.
Title: Re: Could this be a bug ?
Post by: oBFusCATed on May 28, 2017, 01:07:17 am
You can select some code before pressing ctrl-r, then click the all button - the replace will happen only in the selected block of code.
Title: Re: Could this be a bug ?
Post by: BlueHazzard on May 28, 2017, 02:46:34 am

I guess that's the problem,

If I dont hold down the 'Y' key, rather tap it quickly it will replace correctly,
only when I hold it down the editor incorrectly directs the key press.
this is probably a wxWidgets / operating system issue. The replace dialog looses focus to the newly opened editor and so your y gets interpreted as a key pres.
The question here is, how do you control on what part you replace the text if you keep the key pressed. Isn't it jumping around so fast you can't detect if it is the correct place to replace the code? Wouldn't it be better, you follow the way as obfuscated mentioned and mark the code what is to be replaced and select replace all. So you have more control over the process.

What operating system are you using?
Title: Re: Could this be a bug ?
Post by: ashotisatoshi on May 28, 2017, 11:51:47 am

I assumed it would be a scintilla or wxwidgets issue..

I guess it would be simple in enough to set a flag ( i.e in dialog ), so that any keypress
are ignored to the editor
using windows 10,
but problem occurs on all windows
Title: Re: Could this be a bug ?
Post by: oBFusCATed on May 28, 2017, 01:38:18 pm
I guess it would be simple in enough to set a flag ( i.e in dialog ), so that any keypress
Focus issues are never simple nor easy to fix. :(
Title: Re: Could this be a bug ?
Post by: Jenna on May 28, 2017, 01:43:38 pm
The problem is, that the confirmation dialog closes a short time and before it reopens the keyrepeating kicks in and the editor has the focus for a short time.
The easiest way to avoid this is to use the replace-in-selected-text-feature as mentioned by oBFusCATed.

The real bug is, that the replace dialog counts all added chars as replaced chars.
Title: Re: Could this be a bug ?
Post by: ashotisatoshi on May 28, 2017, 04:48:01 pm
@jens,

Exactly what I suspected,  as it is also visually apparent when I hold down
the 'Y' key the dialog opens/closes after each replace ( very quickly of course ) ..
and the OS is redirected the held 'Y' key to the editor when the key repeat
event fires and the dialog is in between closing and reopening ( hiding / showing )

Confirmed:  I always have my keyboard repeat/delay to the shortest possible;
I just decreased the keyboard repeat rate a smidgen and the editor operated correctly...

Possible solution:
I don't know anything about code::blocks/wxwidgets under the hood - but maybe
lose/regain focus in between hiding / showing the dialog. ( i guess this can be done faster than
the keyboard repeat speed )

Anyway - it's not really a bug... - but it a tiny annoyance when working with very large files
and when doing large scale search/replace


Title: Re: Could this be a bug ?
Post by: oBFusCATed on May 28, 2017, 06:14:49 pm
The only real fix for this problem is to not hide the dialog and always keeping the focus in it.