diff options
author | Raphael Isemann <teemperor@gmail.com> | 2020-01-28 10:21:30 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2020-01-28 11:12:22 +0100 |
commit | 243f52b58bcefab68fdebefc6d64f7f0c182c0fe (patch) | |
tree | 2de0c73e3ff91fc910689a71846eb1bf7aee9396 /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | af071f03f379f7f1071e9da23ee4ca26d2c5c509 (diff) | |
download | llvm-243f52b58bcefab68fdebefc6d64f7f0c182c0fe.zip llvm-243f52b58bcefab68fdebefc6d64f7f0c182c0fe.tar.gz llvm-243f52b58bcefab68fdebefc6d64f7f0c182c0fe.tar.bz2 |
[lldb] Cut off unused suffix in CompletionRequest::GetRawLine
The GetRawLine currently returns the full command line used
to create the CompletionRequest. So for example for "foo b[tab] --arg"
it would return the whole string instead of "foo b". Usually
completion code makes the wrong assumption that the cursor is at
the end of the line and handing out the complete line will cause
that people implement completions that also make this assumption.
This patch makes GetRawLine() return only the string until the
cursor and hides the suffix (so that the cursor is always at the
end of this string) and adds another function GetRawLineWithUnusedSuffix
that is specifically the line with the suffix that isn't used by
the CompletionRequest for argument parsing etc.
There is only one user of this new function that actually needs the
suffix and that is the expression command which needs the suffix to
detect if it is in the raw or argument part of the command (by looking
at the "--" separator).
Diffstat (limited to 'lldb/source/Commands/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 6fb6b1d..fabc496 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -311,7 +311,12 @@ void CommandObjectExpression::HandleCompletion(CompletionRequest &request) { target = &GetDummyTarget(); unsigned cursor_pos = request.GetRawCursorPos(); - llvm::StringRef code = request.GetRawLine(); + // Get the full user input including the suffix. The suffix is necessary + // as OptionsWithRaw will use it to detect if the cursor is cursor is in the + // argument part of in the raw input part of the arguments. If we cut of + // of the suffix then "expr -arg[cursor] --" would interpret the "-arg" as + // the raw input (as the "--" is hidden in the suffix). + llvm::StringRef code = request.GetRawLineWithUnusedSuffix(); const std::size_t original_code_size = code.size(); |