Optimize Find As You Type

From MozillaWiki
Jump to: navigation, search

I am often searching 20meg/30meg pages. I'm a Vim user so I'm always using "/" to search through them. The problem is if I make one typo while typing a word, I have to suffer for it for every next letter, waiting one by one while the search feature figures out again and again that the string still isn't in the page.

It would be very easy to remember a "last failed search" (or even a small cache of failed words per age for something more complex) and, from there do a simple check: if the beginning of the new find-as-you-type word matches up with the last failed search then the new one clearly won't as well.

This will be inconsistent when the page is chalk full of DHTML: what if the page modifies content between keystrokes such that the word didn't appear until you were halfway through typing it?

Two solutions to this: 1) invalidate the "last failed search" after you stop typing for a half second or so, or 2) scrap the whole notion of remembering the last failed word and - after a first find failure is detected - just collect the input in the "find" text box without searching for it. A final search after the user has stopped typing (for a half second or so) would account for those rare DHTML circumstances mentioned in the paragraph above.