Fig Completion Specification - Filter Highlight

Fig Completion Specification - Filter Highlight

1月 15, 2024 · 1 分钟阅读时长 · 99 字 · -阅读 -评论

When using Fig, as data is continuously entered, suggestions are continuously filtered and highlighted. Actual testing and analysis revealed the highlighting logic.

Logic

  1. While generating the completion list, calculate N characters from current input command cursor to start matching, defined as charactersToDrop=N
  2. Split N characters into character array, each character performs match highlighting using lazy matching
  3. When user presses enter, terminal first deletes N characters, then writes the matched completion value
  4. 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’

https://static.1991421.cn/2024/2024-01-15-211931.jpeg

Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源