@@ -140,7 +140,7 @@ func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
140140 selectedItem := *s
141141 c.list.SetSelected(selectedItem.ID())
142142 return c, util.CmdHandler(SelectCompletionMsg{
143− Value: selectedItem,
143+ Value: selectedItem.Value(),
144144 Insert: true,
145145 })
146146 case key.Matches(msg, c.keyMap.DownInsert):
@@ -151,7 +151,7 @@ func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
151151 selectedItem := *s
152152 c.list.SetSelected(selectedItem.ID())
153153 return c, util.CmdHandler(SelectCompletionMsg{
154− Value: selectedItem,
154+ Value: selectedItem.Value(),
155155 Insert: true,
156156 })
157157 case key.Matches(msg, c.keyMap.Select):
@@ -162,7 +162,7 @@ func (c *completionsCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
162162 selectedItem := *s
163163 c.open = false // Close completions after selection
164164 return c, util.CmdHandler(SelectCompletionMsg{
165− Value: selectedItem,
165+ Value: selectedItem.Value(),
166166 })
167167 case key.Matches(msg, c.keyMap.Cancel):
168168 return c, util.CmdHandler(CloseCompletionsMsg{})
@@ -272,18 +272,14 @@ func (c *completionsCmp) View() string {
272272// listWidth returns the width of the last 10 items in the list, which is used
273273// to determine the width of the completions popup.
274274// Note this only works for [completionItemCmp] items.
275−func listWidth[T any](items []T) int {
275+func listWidth(items []list.CompletionItem[any]) int {
276276 var width int
277277 if len(items) == 0 {
278278 return width
279279 }
280280
281281 for i := len(items) - 1; i >= 0 && i >= len(items)-10; i-- {
282− item, ok := any(items[i]).(*completionItemCmp)
283− if !ok {
284− continue
285− }
286− itemWidth := lipgloss.Width(item.text) + 2 // +2 for padding
282+ itemWidth := lipgloss.Width(items[i].Text()) + 2 // +2 for padding
287283 width = max(width, itemWidth)
288284 }
289285