Author: friss Date: Fri Aug 31 16:03:28 2018 New Revision: 341268 URL: http://llvm.org/viewvc/llvm-project?rev=341268&view=rev Log: 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. Modified: lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/unittests/Interpreter/TestCompletion.cpp Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=341268&r1=341267&r2=341268&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Fri Aug 31 16:03:28 2018 @@ -166,7 +166,11 @@ static int DiskFilesOrDirectories(const 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()) { Modified: lldb/trunk/unittests/Interpreter/TestCompletion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Interpreter/TestCompletion.cpp?rev=341268&r1=341267&r2=341268&view=diff ============================================================================== --- lldb/trunk/unittests/Interpreter/TestCompletion.cpp (original) +++ lldb/trunk/unittests/Interpreter/TestCompletion.cpp Fri Aug 31 16:03:28 2018 @@ -174,6 +174,11 @@ TEST_F(CompletionTest, DirCompletionAbso 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); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits