[PR #18700] Update command palette search to prioritize "longest substring" match. #31596

Closed
opened 2026-01-31 09:48:16 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/18700

State: closed
Merged: Yes


Summary of the Pull Request

Addresses: https://github.com/microsoft/terminal/issues/6693

Repurposed work from https://github.com/microsoft/terminal/pull/16586

  • I think the fzf algo fits here where it optimizes to find the optimal match based on consecutive chars and word boundaries.
    • There are some edge cases where a match with a small gap could get a higher score than a match of consecutive chars when the match with a gap has other bonuses (FirstChar * Boundary Bonus). This can be adjusted by adjusting the bonuses or removing them if needed.
  • From reading the thread in https://github.com/microsoft/terminal/issues/6693 it looked like you guys were leaning towards something like the fzf algo.
  • License file is now updated in https://github.com/nvim-telescope/telescope-fzf-native.nvim repository
  • Removed the following from the original implementation to minimize complexity and the size of the PR. (Let me know if any of these should be added back).
    • Query expressions "$:StartsWith ^:EndsWith |:Or !:Not etc"
    • Slab to avoid allocating the scoring matrix. This felt like overkill for the number of items in the command pallete.
    • Fallback to V1 algorithm for very long strings. I want to say that the command palette won't have strings this long.
  • Added the logic from GH#9941 that copies pattern and text chars to string for comparision with lstrcmpi
    • It does this twice now which isn't great...

Feel free to close if it doesn't make sense for what ever reason (E.g. License file still an issue, wrong direction for fix, too complex, etc).

palette2

References and Relevant Issues

https://github.com/microsoft/terminal/issues/6693

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

PR Checklist

  • Closes #xxx
  • Tests added/passed
  • Documentation updated
    • If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated (if necessary)
**Original Pull Request:** https://github.com/microsoft/terminal/pull/18700 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Addresses: https://github.com/microsoft/terminal/issues/6693 Repurposed work from https://github.com/microsoft/terminal/pull/16586 - I think the fzf algo fits here where it optimizes to find the optimal match based on consecutive chars and word boundaries. - There are some edge cases where a match with a small gap could get a higher score than a match of consecutive chars when the match with a gap has other bonuses (FirstChar * Boundary Bonus). This can be adjusted by adjusting the bonuses or removing them if needed. - From reading the thread in https://github.com/microsoft/terminal/issues/6693 it looked like you guys were leaning towards something like the fzf algo. - License file is now updated in https://github.com/nvim-telescope/telescope-fzf-native.nvim repository - https://github.com/nvim-telescope/telescope-fzf-native.nvim/pull/148 - https://github.com/junegunn/fzf/issues/4310 - Removed the following from the original implementation to minimize complexity and the size of the PR. (Let me know if any of these should be added back). - Query expressions "$:StartsWith ^:EndsWith |:Or !:Not etc" - Slab to avoid allocating the scoring matrix. This felt like overkill for the number of items in the command pallete. - Fallback to V1 algorithm for very long strings. I want to say that the command palette won't have strings this long. - Added the logic from GH#9941 that copies pattern and text chars to string for comparision with lstrcmpi - It does this twice now which isn't great... Feel free to close if it doesn't make sense for what ever reason (E.g. License file still an issue, wrong direction for fix, too complex, etc). ![palette2](https://github.com/user-attachments/assets/74ecae2b-ba53-4991-bcf2-a79d5b93614d) ## References and Relevant Issues https://github.com/microsoft/terminal/issues/6693 ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed ## PR Checklist - [ ] Closes #xxx - [ ] Tests added/passed - [ ] Documentation updated - If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx - [ ] Schema updated (if necessary)
claunia added the pull-request label 2026-01-31 09:48:17 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31596