forked from lix-project/lix
Merge pull request #7134 from yorickvP/disable-dbg-on-complete
Temporarily disable the debugger during completion evaluation
This commit is contained in:
commit
62960f3291
|
@ -207,6 +207,7 @@ Strings SourceExprCommand::getDefaultFlakeAttrPathPrefixes()
|
||||||
|
|
||||||
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
void SourceExprCommand::completeInstallable(std::string_view prefix)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if (file) {
|
if (file) {
|
||||||
completionType = ctAttrs;
|
completionType = ctAttrs;
|
||||||
|
|
||||||
|
@ -257,6 +258,9 @@ void SourceExprCommand::completeInstallable(std::string_view prefix)
|
||||||
getDefaultFlakeAttrPaths(),
|
getDefaultFlakeAttrPaths(),
|
||||||
prefix);
|
prefix);
|
||||||
}
|
}
|
||||||
|
} catch (EvalError&) {
|
||||||
|
// Don't want eval errors to mess-up with the completion engine, so let's just swallow them
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void completeFlakeRefWithFragment(
|
void completeFlakeRefWithFragment(
|
||||||
|
|
|
@ -384,6 +384,10 @@ StringSet NixRepl::completePrefix(const std::string & prefix)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* Temporarily disable the debugger, to avoid re-entering readline. */
|
||||||
|
auto debug_repl = state->debugRepl;
|
||||||
|
state->debugRepl = nullptr;
|
||||||
|
Finally restoreDebug([&]() { state->debugRepl = debug_repl; });
|
||||||
try {
|
try {
|
||||||
/* This is an expression that should evaluate to an
|
/* This is an expression that should evaluate to an
|
||||||
attribute set. Evaluate it to get the names of the
|
attribute set. Evaluate it to get the names of the
|
||||||
|
|
|
@ -28,6 +28,10 @@ cat <<EOF > bar/flake.nix
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
mkdir -p err
|
||||||
|
cat <<EOF > err/flake.nix
|
||||||
|
throw "error"
|
||||||
|
EOF
|
||||||
|
|
||||||
# Test the completion of a subcommand
|
# Test the completion of a subcommand
|
||||||
[[ "$(NIX_GET_COMPLETIONS=1 nix buil)" == $'normal\nbuild\t' ]]
|
[[ "$(NIX_GET_COMPLETIONS=1 nix buil)" == $'normal\nbuild\t' ]]
|
||||||
|
@ -60,3 +64,5 @@ NIX_GET_COMPLETIONS=3 nix build --option allow-import-from | grep -- "allow-impo
|
||||||
# Attr path completions
|
# Attr path completions
|
||||||
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./foo\#sam)" == $'attrs\n./foo#sampleOutput\t' ]]
|
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./foo\#sam)" == $'attrs\n./foo#sampleOutput\t' ]]
|
||||||
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./foo/flake.nix outp)" == $'attrs\noutputs\t' ]]
|
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./foo/flake.nix outp)" == $'attrs\noutputs\t' ]]
|
||||||
|
[[ "$(NIX_GET_COMPLETIONS=4 nix eval --file ./err/flake.nix outp 2>&1)" == $'attrs' ]]
|
||||||
|
[[ "$(NIX_GET_COMPLETIONS=2 nix eval ./err\# 2>&1)" == $'attrs' ]]
|
||||||
|
|
Loading…
Reference in a new issue