Bug - Fixed race condition in AutoFilterComboBox

roippi

Developer
I believe that's the module, anyway. Maybe AutoFilterTextField, I haven't looked at the code yet. A clannie pointed this one out to me a few weeks ago.

Steps to reproduce:

-Adventure tab, choose guano junction as the zone.
-Enable goals checkbox. Clear the goals field.
-A) slowly type "1 baseball" into the combobox
-B) quickly type "1 baseball" into the combobox

Note good behavior with A) and bad behavior with B).
 

holatuwol

Developer
I'm not sure what the "bad behavior" was, but I did notice that we weren't delaying the update for a fraction of a second in AutoFilterTextField to account for people who type fast (which would result in more calls to the filtering logic than necessary), so I've gone ahead and updated the code to do that.
 

roippi

Developer
Sorry, I should have specified what the behavior is.

This block in AutoFilterComboBox:

Code:
			this.editor.setText( this.currentMatch.toString() );
			this.editor.setCaretPosition( caretPosition );
			this.editor.setSelectionStart( this.currentName.length() );
			this.editor.setSelectionEnd( this.matchString.length() );

Happens when there's a match to the model. It sets the text of the combo box to the match, places the caret at the current position, and highlights the remaining text in the word. Therefore, when the next letter is typed, it overwrites the selected text, and the pattern repeats. Basically what I think of as excel-like autocompletion.

The problem is that if you type very quickly, this does not happen. The caret is placed at the end of the word, and subsequent letters are appended to the end of the word. So I end up with something like "1 baseballaseball".

It looks like the new revision maintains this behavior.
 

Winterbay

Active member
The same thing is reproducible in the Purchase-tab, I tend to search for strange things all the time due to this :)
 

roippi

Developer
You guys know you're allowed to report bugs, right? :p

But yes, those instances are all the same bug.
 

Winterbay

Active member
I've never thought of it as a bug, just me not thinking and not understanding how the autocomplete-thingie worked :)
 

roippi

Developer
Huh. That works. I don't even care to mention the crazy workarounds that I came up with.

r11169
 

Catch-22

Active member
I had a feeling that would be happening :D

Edit: It's probably worth noting that setSelectionStart() and setSelectionEnd() are deprecated and any occurrences should eventually be moved over to setCaretPosition() and moveCaretPosition().
 
Last edited:
Top