This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe8966125e281: [lldb/Commands] Fix disk completion from root directory (authored by mib).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152013/new/ https://reviews.llvm.org/D152013 Files: lldb/source/Commands/CommandCompletions.cpp lldb/test/API/functionalities/completion/TestCompletion.py Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -477,6 +477,19 @@ self.complete_from_to("my_test_cmd main.cp", ["main.cpp"]) self.expect("my_test_cmd main.cpp", substrs=["main.cpp"]) + def test_completion_target_create_from_root_dir(self): + """Tests source file completion by completing .""" + root_dir = os.path.abspath(os.sep) + self.completions_contain( + "target create " + root_dir, + list( + filter( + lambda x: os.path.exists(x), + map(lambda x: root_dir + x + os.sep, os.listdir(root_dir)), + ) + ), + ) + def test_target_modules_load_aout(self): """Tests modules completion by completing the target modules load argument.""" self.build() Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -381,6 +381,8 @@ Storage.append(RemainderDir); } SearchDir = Storage; + } else if (CompletionBuffer == path::root_directory(CompletionBuffer)) { + SearchDir = CompletionBuffer; } else { SearchDir = path::parent_path(CompletionBuffer); } @@ -390,9 +392,11 @@ 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()) {
Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -477,6 +477,19 @@ self.complete_from_to("my_test_cmd main.cp", ["main.cpp"]) self.expect("my_test_cmd main.cpp", substrs=["main.cpp"]) + def test_completion_target_create_from_root_dir(self): + """Tests source file completion by completing .""" + root_dir = os.path.abspath(os.sep) + self.completions_contain( + "target create " + root_dir, + list( + filter( + lambda x: os.path.exists(x), + map(lambda x: root_dir + x + os.sep, os.listdir(root_dir)), + ) + ), + ) + def test_target_modules_load_aout(self): """Tests modules completion by completing the target modules load argument.""" self.build() Index: lldb/source/Commands/CommandCompletions.cpp =================================================================== --- lldb/source/Commands/CommandCompletions.cpp +++ lldb/source/Commands/CommandCompletions.cpp @@ -381,6 +381,8 @@ Storage.append(RemainderDir); } SearchDir = Storage; + } else if (CompletionBuffer == path::root_directory(CompletionBuffer)) { + SearchDir = CompletionBuffer; } else { SearchDir = path::parent_path(CompletionBuffer); } @@ -390,9 +392,11 @@ 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()) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits