aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandCompletions.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <ismail@bennani.ma>2023-06-05 13:19:44 -0700
committerMed Ismail Bennani <ismail@bennani.ma>2023-06-06 10:58:34 -0700
commite8966125e2812f08bf0f548bf576981025d44cbd (patch)
treeee8b2cd38eee6ea6bb3ca714f7e26478943b38ec /lldb/source/Commands/CommandCompletions.cpp
parent3bc0baf9d43967d828e2d311f6c0863e79158f07 (diff)
downloadllvm-e8966125e2812f08bf0f548bf576981025d44cbd.zip
llvm-e8966125e2812f08bf0f548bf576981025d44cbd.tar.gz
llvm-e8966125e2812f08bf0f548bf576981025d44cbd.tar.bz2
[lldb/Commands] Fix disk completion from root directory
This patch should fix path completion starting from the root directory. To do so, this patch adds a special case when setting the search directory when the completion buffer points to the root directory. Differential Revision: https://reviews.llvm.org/D152013 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/source/Commands/CommandCompletions.cpp')
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index 1fe25d9..35237d4 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -381,6 +381,8 @@ static void DiskFilesOrDirectories(const llvm::Twine &partial_name,
Storage.append(RemainderDir);
}
SearchDir = Storage;
+ } else if (CompletionBuffer == path::root_directory(CompletionBuffer)) {
+ SearchDir = CompletionBuffer;
} else {
SearchDir = path::parent_path(CompletionBuffer);
}
@@ -390,9 +392,11 @@ static void DiskFilesOrDirectories(const llvm::Twine &partial_name,
PartialItem = path::filename(CompletionBuffer);
// 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()))
+ // directory separator or the separator when passed the disk root directory.
+ // We have to filter those out, but only when the "." doesn't come from the
+ // completion request itself.
+ if ((PartialItem == "." || PartialItem == path::get_separator()) &&
+ path::is_separator(CompletionBuffer.back()))
PartialItem = llvm::StringRef();
if (SearchDir.empty()) {