Skip to content

Commit

Permalink
fix: auto_show function logic
Browse files Browse the repository at this point in the history
This code was reduced by a line before merging PR Saghen#697, but it's now
hitting the case where the Lua 'ternary' doesn't behave like a proper
ternary operator. Specifically, when the `auto_show` function returns
false, the result of
```lua
auto_show = type(auto_show) == "function" and auto_show(...) or auto_show
```
becomes
```lua
auto_show = (true and false) or <function>
```
which is the truthy function reference itself.
  • Loading branch information
guill committed Dec 21, 2024
1 parent a937edd commit 4ba2cb9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/blink/cmp/completion/windows/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ function menu.open_with_items(context, items)
if not menu.renderer then menu.renderer = require('blink.cmp.completion.windows.render').new(config.draw) end
menu.renderer:draw(context, menu.win:get_buf(), items)

local auto_show = type(menu.auto_show) == 'function' and menu.auto_show(context, items) or menu.auto_show
local auto_show = menu.auto_show
if type(auto_show) == 'function' then auto_show = auto_show(context, items) end
if auto_show then
menu.open()
menu.update_position()
Expand Down

0 comments on commit 4ba2cb9

Please sign in to comment.