Allow keys to contain "is" and "?"#403
Open
randomPoison wants to merge 2 commits intodesert-planet:masterfrom
Open
Allow keys to contain "is" and "?"#403randomPoison wants to merge 2 commits intodesert-planet:masterfrom
randomPoison wants to merge 2 commits intodesert-planet:masterfrom
Conversation
* Change the regex to strip the last "?" from the string, rather then stopping at the first "?". * Use the stripped string in the final fallback case to make sure the final message correctly reflects the key that we attempted to look up.
Contributor
Author
|
Also it might be a good idea to merge #384 before this one, that way I can also add tests to the rem tests script added in that PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for having "is" in the key for memories, allowing us to save memories with names like "why is it going down". In order to support this, I've had to refactor the handler to change the order of the operations performed by the handler.
The reason that is necessary is because the current logic makes it so you can never retrieve a key that contains "is". For example, if we had a memory named "a is b", we would try to retrieve it with
.rem a is b. But this will be interpreted as a request to create a new memory "a" with the value "b". To make it possible to have "is" in the key, we need to first check if the entire phrase matches an existing key. If it doesn't, we can then attempt to interpret it as a request to store a new key.I also changed the handling of "?", allowing keys containing "?" to be remembered. The current logic will only use the text before the first "?", so if you tried to remember a key named "hello?" it would always instead search for a memory named "hello". This PR changes the logic to instead use the text up to the last "?". This means that searching for "hello?" will still look for a memory named "hello". But you can search for keys that contain a "?" by adding an extra "?" at the end, i.e. you'd do
.rem hello??to retrieve the key "hello?".