Fig Completion Specification - Filter Highlight
·
1 min read
When using Fig, as data is continuously entered, suggestions are continuously filtered and highlighted. Actual testing and analysis revealed the highlighting logic.
Logic
- While generating the completion list, calculate N characters from current input command cursor to start matching, defined as charactersToDrop=N
- Split N characters into character array, each character performs match highlighting using lazy matching
- When user presses enter, terminal first deletes N characters, then writes the matched completion value
- User presses enter to select suggestion
Example
Input cd ar
, charactersToDrop=2
Each character performs matching. After ‘a’ matches, ‘r’ continues to match, but ‘r’ must match after ‘a’