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
This commit is contained in:
parent
a69696dca6
commit
78a10a7a9b
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue