|
17 | 17 | function Source:get_completions(ctx, callback)
|
18 | 18 | local line = ctx.line:sub(1, ctx.cursor[2])
|
19 | 19 | local offset = org.completion:get_start({ line = line }) + 1
|
20 |
| - local base = string.sub(line, offset) |
| 20 | + local full_base = string.sub(line, offset) |
| 21 | + |
| 22 | + -- Create a simplified base that preserves completion context but avoids over-filtering |
| 23 | + local simplified_base = full_base |
| 24 | + |
| 25 | + -- For file links, keep only the protocol part to preserve context |
| 26 | + if full_base:match('^file:') then |
| 27 | + simplified_base = 'file:' |
| 28 | + elseif full_base:match('^~/') then |
| 29 | + simplified_base = '~/' |
| 30 | + elseif full_base:match('^%./') then |
| 31 | + simplified_base = './' |
| 32 | + elseif full_base:match('^/') then |
| 33 | + simplified_base = '/' |
| 34 | + -- For other contexts, use a minimal base to get all results |
| 35 | + elseif full_base:match('^%*') then |
| 36 | + simplified_base = '*' |
| 37 | + elseif full_base:match('^#%+') then |
| 38 | + simplified_base = '#+' |
| 39 | + elseif full_base:match('^:') then |
| 40 | + simplified_base = ':' |
| 41 | + end |
| 42 | + |
| 43 | + -- Pass simplified base to orgmode sources to preserve context but get more results |
21 | 44 | local results = org.completion:complete({
|
22 | 45 | line = line,
|
23 |
| - base = base, |
| 46 | + base = simplified_base, |
| 47 | + framework = 'blink', -- Still signal framework for any remaining filtering |
24 | 48 | })
|
25 | 49 |
|
26 | 50 | local cb = function(items)
|
@@ -55,14 +79,16 @@ function Source:get_completions(ctx, callback)
|
55 | 79 | return 0
|
56 | 80 | end
|
57 | 81 |
|
58 |
| - local baseOffset = getInsertTextOffset(base) |
| 82 | + -- Use full_base for insertText calculation |
| 83 | + local baseOffset = getInsertTextOffset(full_base) |
59 | 84 | local insertTextOffset = baseOffset > 0 and math.max(2, baseOffset) or 0
|
60 | 85 |
|
61 | 86 | local items = {}
|
62 | 87 |
|
63 | 88 | for _, item in ipairs(results) do
|
64 | 89 | table.insert(items, {
|
65 | 90 | label = item.word,
|
| 91 | + filterText = item.word, -- Text to fuzzy match against |
66 | 92 | insertText = insertTextOffset > 0 and item.word:sub(insertTextOffset) or item.word,
|
67 | 93 | labelDetails = item.menu and { description = item.menu } or nil,
|
68 | 94 | })
|
|
0 commit comments