summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2018-08-31 23:03:28 +0000
committerFrederic Riss <friss@apple.com>2018-08-31 23:03:28 +0000
commit78a10a7a9bb2d56a10dabae58ebd488055b1d828 (patch)
tree7149568a565e38a44e046c84c983c8e2788fdabc
parenta69696dca625cf9aed22988bd1c0d56a752221f6 (diff)
downloadbcm5719-llvm-78a10a7a9bb2d56a10dabae58ebd488055b1d828.tar.gz
bcm5719-llvm-78a10a7a9bb2d56a10dabae58ebd488055b1d828.zip
File completion bugfix
If you tried to complete somwthing like ~/., lldb would come up with a lot of non-existent filenames by concatenating every exisitng file in the directory with an initial '.'. This was due to a workaround for an llvm::fs::path::filename behavior that was not applied selectively enough. llvm-svn: 341268
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp6
-rw-r--r--lldb/unittests/Interpreter/TestCompletion.cpp5
2 files changed, 10 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 7b351c50dc6..fc3e8d0662d 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -166,7 +166,11 @@ static int DiskFilesOrDirectories(const llvm::Twine &partial_name,
size_t FullPrefixLen = CompletionBuffer.size();
PartialItem = path::filename(CompletionBuffer);
- if (PartialItem == ".")
+
+ // path::filename() will return "." when the passed path ends with a
+ // directory separator. We have to filter those out, but only when the
+ // "." doesn't come from the completion request itself.
+ if (PartialItem == "." && path::is_separator(CompletionBuffer.back()))
PartialItem = llvm::StringRef();
if (SearchDir.empty()) {
diff --git a/lldb/unittests/Interpreter/TestCompletion.cpp b/lldb/unittests/Interpreter/TestCompletion.cpp
index 12c16a98b91..47f364ebe53 100644
--- a/lldb/unittests/Interpreter/TestCompletion.cpp
+++ b/lldb/unittests/Interpreter/TestCompletion.cpp
@@ -174,6 +174,11 @@ TEST_F(CompletionTest, DirCompletionAbsolute) {
ASSERT_EQ(Count, Results.GetSize());
EXPECT_TRUE(HasEquivalentFile(BaseDir, Results));
+ Count =
+ CommandCompletions::DiskDirectories(Twine(BaseDir) + "/.", Results, Resolver);
+ ASSERT_EQ(0u, Count);
+ ASSERT_EQ(Count, Results.GetSize());
+
// When the same directory ends with a slash, it finds all children.
Count = CommandCompletions::DiskDirectories(Prefixes[0], Results, Resolver);
ASSERT_EQ(7u, Count);
OpenPOWER on IntegriCloud