-
Notifications
You must be signed in to change notification settings - Fork 168
Autocompletion
When a user begins typing in the editor, the autocomplete function suggests keywords and names that may be appropriate in that context to aid the user.
When the user types in at least one letter, a prompt is displayed indicating possible names that may be useful to the user based on the current input and cursor location. If documentation is available for built-in functions, such documentation is also displayed. Suggestions are refined as the user types in more letters.
The user is able to scroll down the list of suggested autocompletions using the arrow keys or cursor, and can press Enter
, Tab
, or use the cursor to select the appropriate suggestion from the prompt box.
Depending on the context in which the user's cursor is located, different types of keywords are suggested in the prompt. In the condition statement of a for-loop, only the let
keyword is allowed. Similarly, keywords that can only occur at the start of a line, such as if
, are only suggested when the cursor is at the start of a line.
In other contexts, autocompletion is turned off. Prompts are not displayed in comments, when the user is naming a variable, or when the user is inputting parameters to a function.
Variable and function names declared in the editor itself are also suggested by the autocomplete function. For more information on which names are suggested, see js-slang/autocomplete. In general, names that are within the cursor's current scope will be suggested by the autocompletion prompt.
Built-in and external library function names and their associated documentation are also displayed in the autocomplete prompt. For instance, when the runes
library is used, those functions can be selected from the autocomplete prompt. Built-in and external library names are always suggested after the relevant keywords and locally-declared names, if they exist.