HirokiImai updated this revision to Diff 369412. HirokiImai added a comment.
Add a regression test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D108817/new/ https://reviews.llvm.org/D108817 Files: lldb/source/Host/common/Editline.cpp lldb/test/API/iohandler/completion/Makefile lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py Index: lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py =================================================================== --- lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py +++ lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py @@ -20,7 +20,8 @@ @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr49408') @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_completion(self): - self.launch(dimensions=(100,500)) + self.build() + self.launch(dimensions=(100,500), executable=self.getBuildArtifact("a.out")) # Start tab completion, go to the next page and then display all with 'a'. self.child.send("\t\ta") @@ -51,6 +52,13 @@ self.child.send("\n") self.expect_prompt() + # Complete a file path. + # FIXME: This should complete to './main.c' and not 'main.c' + self.child.send("breakpoint set --file ./main\t") + self.child.expect_exact("main.c") + self.child.send("\n") + self.expect_prompt() + # Start tab completion and abort showing more commands with 'n'. self.child.send("\t") self.child.expect_exact("More (Y/n/a)") Index: lldb/test/API/iohandler/completion/Makefile =================================================================== --- /dev/null +++ lldb/test/API/iohandler/completion/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules Index: lldb/source/Host/common/Editline.cpp =================================================================== --- lldb/source/Host/common/Editline.cpp +++ lldb/source/Host/common/Editline.cpp @@ -1006,11 +1006,11 @@ switch (completion.GetMode()) { case CompletionMode::Normal: { std::string to_add = completion.GetCompletion(); - to_add = to_add.substr(request.GetCursorArgumentPrefix().size()); // Terminate the current argument with a quote if it started with a quote. if (!request.GetParsedLine().empty() && request.GetParsedArg().IsQuoted()) to_add.push_back(request.GetParsedArg().GetQuoteChar()); to_add.push_back(' '); + el_deletestr(m_editline, request.GetCursorArgumentPrefix().size()); el_insertstr(m_editline, to_add.c_str()); // Clear all the autosuggestion parts if the only single space can be completed. if (to_add == " ")
Index: lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py =================================================================== --- lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py +++ lldb/test/API/iohandler/completion/TestIOHandlerCompletion.py @@ -20,7 +20,8 @@ @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr49408') @skipIf(oslist=["linux"], archs=["arm", "aarch64"]) def test_completion(self): - self.launch(dimensions=(100,500)) + self.build() + self.launch(dimensions=(100,500), executable=self.getBuildArtifact("a.out")) # Start tab completion, go to the next page and then display all with 'a'. self.child.send("\t\ta") @@ -51,6 +52,13 @@ self.child.send("\n") self.expect_prompt() + # Complete a file path. + # FIXME: This should complete to './main.c' and not 'main.c' + self.child.send("breakpoint set --file ./main\t") + self.child.expect_exact("main.c") + self.child.send("\n") + self.expect_prompt() + # Start tab completion and abort showing more commands with 'n'. self.child.send("\t") self.child.expect_exact("More (Y/n/a)") Index: lldb/test/API/iohandler/completion/Makefile =================================================================== --- /dev/null +++ lldb/test/API/iohandler/completion/Makefile @@ -0,0 +1,3 @@ +C_SOURCES := main.c + +include Makefile.rules Index: lldb/source/Host/common/Editline.cpp =================================================================== --- lldb/source/Host/common/Editline.cpp +++ lldb/source/Host/common/Editline.cpp @@ -1006,11 +1006,11 @@ switch (completion.GetMode()) { case CompletionMode::Normal: { std::string to_add = completion.GetCompletion(); - to_add = to_add.substr(request.GetCursorArgumentPrefix().size()); // Terminate the current argument with a quote if it started with a quote. if (!request.GetParsedLine().empty() && request.GetParsedArg().IsQuoted()) to_add.push_back(request.GetParsedArg().GetQuoteChar()); to_add.push_back(' '); + el_deletestr(m_editline, request.GetCursorArgumentPrefix().size()); el_insertstr(m_editline, to_add.c_str()); // Clear all the autosuggestion parts if the only single space can be completed. if (to_add == " ")
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits