Skip to content

Commit 12b4f11

Browse files
committed
feat: use filter_text when available
1 parent a9f77d8 commit 12b4f11

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lua/blink/cmp/fuzzy/fuzzy.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ pub fn fuzzy(
5656
opts: FuzzyOptions,
5757
) -> Vec<usize> {
5858
let nearby_words: HashSet<String> = HashSet::from_iter(opts.nearby_words.unwrap_or_default());
59-
let haystack_labels = haystack.iter().map(|s| s.label.clone()).collect::<Vec<_>>();
59+
let haystack_labels = haystack
60+
.iter()
61+
.map(|s| s.filter_text.clone().unwrap_or(s.label.clone()))
62+
.collect::<Vec<_>>();
6063

6164
// Fuzzy match with fzrs
6265
let options = frizbee::Options {

lua/blink/cmp/fuzzy/lsp_item.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use mlua::prelude::*;
33
#[derive(Debug)]
44
pub struct LspItem {
55
pub label: String,
6+
pub filter_text: Option<String>,
67
pub kind: u32,
78
pub score_offset: i32,
89
pub source_id: String,
@@ -11,13 +12,15 @@ pub struct LspItem {
1112
impl FromLua for LspItem {
1213
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
1314
if let Some(tab) = value.as_table() {
14-
let label: String = tab.get("label").unwrap_or_default();
15-
let kind: u32 = tab.get("kind").unwrap_or_default();
16-
let score_offset: i32 = tab.get("score_offset").unwrap_or(0);
17-
let source_id: String = tab.get("source_id").unwrap_or_default();
15+
let label = tab.get("label").unwrap_or_default();
16+
let filter_text = tab.get("filter_text").ok();
17+
let kind = tab.get("kind").unwrap_or_default();
18+
let score_offset = tab.get("score_offset").unwrap_or(0);
19+
let source_id = tab.get("source_id").unwrap_or_default();
1820

1921
Ok(LspItem {
2022
label,
23+
filter_text,
2124
kind,
2225
score_offset,
2326
source_id,

0 commit comments

Comments
 (0)