mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
Don't query typeahead for one-char inputs
Summary: The typeahead gives poor results when you only type one character, and those queries are much slower than two+ character queries. Let's just limit our fetch to only happen for 2+ characters typed. Some typeaheads even limit to 3+, but I think we can handle 2+. Reviewed By: quark-zju Differential Revision: D45665010 fbshipit-source-id: e4743550ee33352fd3a0cbe6f1df974513d1ec40
This commit is contained in:
parent
5a54b96cff
commit
3913e7a1ab
@ -185,8 +185,9 @@ async function fetchNewSuggestions(
|
||||
text: string,
|
||||
): Promise<{values: Array<TypeaheadResult>; fetchStartTimestamp: number}> {
|
||||
const now = Date.now();
|
||||
if (text.trim() === '') {
|
||||
// no need to do a fetch on empty input
|
||||
if (text.trim().length < 2) {
|
||||
// no need to do a fetch on zero- or one-char input...
|
||||
// it's slow and doesn't give good suggestions anyway
|
||||
return {values: [], fetchStartTimestamp: now};
|
||||
}
|
||||
const id = randomId();
|
||||
|
Loading…
Reference in New Issue
Block a user