summaryrefslogtreecommitdiff
path: root/src/commands.cc
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-11-12 12:37:35 +0100
committerJohannes Altmanninger <aclopte@gmail.com>2022-11-19 15:20:31 +0100
commit59b8b99577ce38bc2b3cad330c1108eeb4faa447 (patch)
tree090fc69c9bdae6823a3049379e6dc315d0927375 /src/commands.cc
parent91d45a100a39345f06d9789ded9172fe60887c27 (diff)
Accept "cd dir/" again instead of using a subdirectory
Commit 69053d962 (Use menu behavior when completing change-directory, 2022-07-19) made ":cd dir/" actually run ":cd dir/first-subdir", which can be surprising. This is usually irrelevant because you rarely type the trailing slash. However it does happen after correcting an error with `<backspace>` and friends. For for example, :cd d<tab>/f<backspace> results in :cd dir/ We should probably fix user expectations here. Do this by adding "dir/" as valid completion. This requires us to allow empty candidates in "RankedMatch" but there's no harm in that. This means we need to filter out empty completions from shell-script-candidates elsewhere. Alternative fix: we could revert 69053d962. This would remove the convenient menu behavior but that wouldn't be a huge deal. Fixes #4775
Diffstat (limited to 'src/commands.cc')
-rw-r--r--src/commands.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 123736b0..bb067699 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -241,7 +241,8 @@ struct ShellScriptCompleter
ShellManager::Flags::WaitForStdout,
shell_context).first;
CandidateList candidates;
- for (auto&& candidate : output | split<StringView>('\n'))
+ for (auto&& candidate : output | split<StringView>('\n')
+ | filter([](auto s) { return not s.empty(); }))
candidates.push_back(candidate.str());
return {0_byte, pos_in_token, std::move(candidates), m_flags};
@@ -274,7 +275,8 @@ struct ShellCandidatesCompleter
ShellManager::Flags::WaitForStdout,
shell_context).first;
m_candidates.clear();
- for (auto c : output | split<StringView>('\n'))
+ for (auto c : output | split<StringView>('\n')
+ | filter([](auto s) { return not s.empty(); }))
m_candidates.emplace_back(c.str(), used_letters(c));
m_token = token_to_complete;
}