This is an archive of the discontinued LLVM Phabricator instance.

[EditLine] Fix RecallHistory that makes it move in the opposite direction.
ClosedPublic

Authored by JDevlieghere on Dec 2 2019, 3:58 PM.

Details

Summary

The naming used by editline for the history operations is counter
intuitive to how it's used in lldb for the REPL.

  • The H_PREV operation returns the previous element in the history, which is newer than the current one.
  • The H_NEXT operation returns the next element in the history, which is older than the current one.

This exposed itself as a bug in the REPL where the behavior of up- and
down-arrow was inverted. This wasn't immediately obvious because of how we save
the current "live" entry.

This patch fixes the bug and introduces and enum to wrap the editline
operations that match the semantics of lldb.

Diff Detail

Event Timeline

JDevlieghere created this revision.Dec 2 2019, 3:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 2 2019, 3:58 PM
Herald added a subscriber: abidh. · View Herald Transcript

(No test because this code is only used by the REPL)

labath added a comment.Dec 3 2019, 1:20 AM

... this code is only used by the REPL)

Are you sure about that? I think I was able to trigger something like this by entering the multiline expression mode (expr) , and then pressing alt+up/down. I'm not 100% sure of that's the thing you're fixing here, because i've never used this feature (though it is pretty cool), but my impression is that this is it.

teemperor accepted this revision.Dec 3 2019, 4:37 AM

Yes, multiline expressions use this code, but I don't see any functional change in this patch that could be tested? It seems to only change the bool to an enum so that we can pass in Swift Newer/Older instead of cryptic true/false (and the actual fix is swapping this in swift-lldb).

Anyway, I added a test for going up/down in multiline expressions in rG4821d2a014e02b14223676c98b2ef5244eb91da8. As this seems NFC and the changed code is now tested, this can land.

This revision is now accepted and ready to land.Dec 3 2019, 4:37 AM
labath added a comment.Dec 3 2019, 4:44 AM

Yes, multiline expressions use this code, but I don't see any functional change in this patch that could be tested? It seems to only change the bool to an enum so that we can pass in Swift Newer/Older instead of cryptic true/false (and the actual fix is swapping this in swift-lldb).

Anyway, I added a test for going up/down in multiline expressions in rG4821d2a014e02b14223676c98b2ef5244eb91da8. As this seems NFC and the changed code is now tested, this can land.

Yes, that makes sense. And thank you for adding the test!

This revision was automatically updated to reflect the committed changes.