X.Prompt: fix selection not entering history

When `alwaysHighlight` is enabled and one immediately presses (by
default) Return after opening the prompt (because the highlighted
completion is what one wants) then the selection will not enter the
prompt history.  Instead, an empty string will be entered because there
hasn't been any input yet and hence the `highlightedCompl` field has not
yet been filled in.

The fix is simply checking whether `alwaysHighlight` is set during
startup and, if yes, already setting the highlighted completion to the
first suggestion.
This commit is contained in:
slotThe 2021-04-09 15:29:51 +02:00
parent d7ad486a6e
commit 828983060d

View File

@ -611,6 +611,10 @@ runXP st = do
(\status -> (\status ->
execStateT execStateT
(when (status == grabSuccess) $ do (when (status == grabSuccess) $ do
ah <- gets (alwaysHighlight . config)
when ah $ do
compl <- listToMaybe <$> getCompletions
modify' $ \xpst -> xpst{ highlightedCompl = compl }
updateWindows updateWindows
eventLoop handleMain evDefaultStop) eventLoop handleMain evDefaultStop)
st st