[lldb] Cut off unused suffix in CompletionRequest::GetRawLine
authorRaphael Isemann <teemperor@gmail.com>
Tue, 28 Jan 2020 09:21:30 +0000 (10:21 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Tue, 28 Jan 2020 10:12:22 +0000 (11:12 +0100)
commit243f52b58bcefab68fdebefc6d64f7f0c182c0fe
tree2de0c73e3ff91fc910689a71846eb1bf7aee9396
parentaf071f03f379f7f1071e9da23ee4ca26d2c5c509
[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).
lldb/include/lldb/Utility/CompletionRequest.h
lldb/source/Commands/CommandObjectExpression.cpp
lldb/unittests/Utility/CompletionRequestTest.cpp