-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Rewrite Swift completion logic in REPL to not crash [WIP] #662
Conversation
3cef7d5
to
cfbb899
Compare
@@ -104,7 +104,7 @@ class CompletionRequest { | |||
|
|||
llvm::StringRef GetRawLine() const { return m_command; } | |||
llvm::StringRef GetRawLineUntilCursor() const { | |||
return m_command.substr(0, m_cursor_index); | |||
return m_command.substr(0, m_raw_cursor_pos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a way to test this change? Is it tested as part of your other commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two of the commits here are not Swift-specific so I'll make a separate PR for them to the stable branch once this passes the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, somehow my commented ended up in this thread.... I just pushed a unit test for this change too.
@swift-ci test |
cfbb899
to
42e4f7f
Compare
@swift-ci test |
Seems like the REPL fails to start as it doesn't reach the start prompt |
@swift-ci test |
In some environments (typically, buildbots), this variable may not be available. This can cause tests to behave differently. Explicitly set the variable to "vt100" to ensure consistent test behavior. It should not matter that we do not inherit the process TERM variable, as the child process runs in a new virtual terminal anyway.
…ong result By using m_cursor_index and not m_raw_cursor_pos in this function we return the characters until the argument index (not the character index). This means that for "foo" (cursor at the end of the string) this returns "" instead of "foo" (as the argument index is 0 for the first argument and not 4 which is the character index at the end). This lead to a crash in the REPL completion where it would cause that we would complete the string "ABC" to " " as we think the line is actually empty and we want to provide the indentation string. Note that the function has already been deleted upstream so this bug doesn't exist there.
42e4f7f
to
615045d
Compare
@swift-ci test |
This removes all the workaround and problematic code that was needed for the old interface. With the CompletionRequest we no longer need to calculate the common prefix ourselves and we don't need to calculate the magic return value. On the other hand we can no longer provide 'appendix' completions (E.g. completing "Suff" with "ix", instead we now need to provide the completion "Suffix"), so in one case we now need to prefix the completion with the existing prefix from the CompletionRequest (as Swift only returns the string to append and not the whole token). Also rewrites the TestSwiftREPLCompletion.py to test all the problematic cases and some more.
615045d
to
28f284d
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Thanks for taking care of it.
[We should try to get this to 4.2] |
I mean, 5.2 |
Do you still plan to merge this PR into
causes:
edit: Indeed, I patched this in and it fixes that crash. |
Ah, yeah, this patch landed in 5.2, I need to do the same PR for all the other branches I guess. Thanks for the hint |
@marcrasi it's on master now, thanks! |
This fixes the crashes in the Swift REPL.
Fixes rdar://58854651