suggest(line: string,sources: Sources): string
The rest of what is being typed, drawn after the cursor — zsh's autosuggestion.
Names before history, and the SHORTEST name first. doc means document far more often than it
means the last thing you happened to do to document, and a suggestion that jumps straight to
document.title is one you have to delete back to the part you wanted. Once document is
taken, history extends it — the two sources hand off rather than compete.
Keywords only where a page name did not match and at least three characters are in — so con
still finishes as console rather than const, and a lone d is not delete.
Returns only the REMAINDER, so a caller can render it after the cursor without measuring anything. Empty when nothing matches, when the line is empty, or when the only match is what is already typed — suggesting that is noise.
import { suggest } from './suggest.ts'; suggest('doc', { names: ['document', 'documentPictureInPicture'] }); // 'ument' suggest('doc', { history: ['document.title'] }); // 'ument.title' — nothing better on offer suggest('document', { names: ['document'], history: ['document.title'] }); // '.title' suggest('', { history: ['anything'] }); // '' — an empty line suggests nothing
sources: Sources