 : hide-completion-popup ( popup -- )
     find-world hide-glass ;
 
-: completion-loc/doc ( popup -- loc doc )
-    interactor>> [ editor-caret ] [ model>> ] bi ;
+: completion-loc/doc/elt ( popup -- loc doc elt )
+    [ interactor>> [ editor-caret ] [ model>> ] bi ]
+    [ completion-mode>> completion-element ]
+    bi ;
 
 GENERIC: completion-string ( object -- string )
 

GENERIC# accept-completion-hook 1 ( item popup -- )

: insert-completion ( item popup -- )
    [ completion-string ] [ completion-loc/doc ] bi*
    one-word-elt set-elt-string ;

: accept-completion ( item table -- )
    find-completion-popup

M: char-completion completion-banner drop "Unicode code point names:" ;
M: history-completion completion-banner drop "Input history:" ;

GENERIC: completion-popup-width ( interactor completion-mode -- x )

M: object completion-popup-width 2drop 300 ;
M: history-completion completion-popup-width drop dim>> first ;

! Completion modes also implement the row renderer protocol
M: listener-completion row-columns drop present 1array ;

