fish-completion: leave the shell prompt intact

When generating shell completions, no logging output should be visible because
it would destroy the shell prompt. Originally this was attempted to be done by
simply disabling the progress bar (ca946860ce),
since the situation is particularly bad there (the screen clearing required for
the rendering ends up erasing the shell prompt). Due to overlooking the
implementation of this hack, it was accidentally undone during a later change
(0dd1d8ca1c).
Since even with the hack correctly in place, it is still possible to mess up
the prompt by logging output (for example warnings for disabled experimental
features, or messages generated by `builtins.trace`), simply send it to the bit
bucket where it belongs. This was already done for bash and zsh
(9d840758a8), and it seems that fish was simply
missed at that time. The last trace of the no-longer-working and obsolete hack
is deleted too.

Fixes: #513
Change-Id: I59f1ebf90903034e2059298fa8d76bf970bc3315
This commit is contained in:
alois31 2024-09-11 18:46:54 +02:00
parent 24db81eaf2
commit 82aa1ccab4
Signed by: alois31
GPG key ID: E0F59EA5E5216914
2 changed files with 2 additions and 2 deletions

View file

@ -14,7 +14,7 @@ function _nix_complete
# But the variable also misses the current token so it cancels out. # But the variable also misses the current token so it cancels out.
set -l nix_arg_to_complete (count $nix_args) set -l nix_arg_to_complete (count $nix_args)
env NIX_GET_COMPLETIONS=$nix_arg_to_complete $nix_args $current_token env NIX_GET_COMPLETIONS=$nix_arg_to_complete $nix_args $current_token 2>/dev/null
end end
function _nix_accepts_files function _nix_accepts_files

View file

@ -7,7 +7,7 @@ namespace nix {
LogFormat defaultLogFormat = LogFormat::raw; LogFormat defaultLogFormat = LogFormat::raw;
LogFormat parseLogFormat(const std::string & logFormatStr) { LogFormat parseLogFormat(const std::string & logFormatStr) {
if (logFormatStr == "raw" || getEnv("NIX_GET_COMPLETIONS")) if (logFormatStr == "raw")
return LogFormat::raw; return LogFormat::raw;
else if (logFormatStr == "raw-with-logs") else if (logFormatStr == "raw-with-logs")
return LogFormat::rawWithLogs; return LogFormat::rawWithLogs;