-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
Add support for stream + topic autocomplete #1004
Conversation
5352028
to
1164b75
Compare
zulipterminal/ui_tools/boxes.py
Outdated
else: | ||
topic_names = [] | ||
|
||
stream_prefix = f"#**{stream}>" |
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.
Is there a reason you aren't using prefix_string
directly here. On doing a quick check, I don't think we need this new variable.
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.
Thanks. I updated the PR to get the required prefix using prefix_string
@Ezio-Sarthak Thanks for taking this up. I tested this locally and it seems to work fine 👍🏼. |
1164b75
to
2c0a2f2
Compare
f729812
to
935ffdd
Compare
@zulipbot add "feedback wanted" |
935ffdd
to
3e8fe4e
Compare
3e8fe4e
to
9fb9df2
Compare
9fb9df2
to
67ebf26
Compare
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.
Thanks for working on this @Ezio-Sarthak!
This work and the extension to the autocomplete looks good to me and functions well too 👍! I've left a couple of minor suggestions in-line.
zulipterminal/ui_tools/boxes.py
Outdated
m = re.search(REGEX_AUTOCOMPLETE_STREAM_TOPIC, text) | ||
m_fenced = re.search(REGEX_AUTOCOMPLETE_STREAM_TOPIC_FENCED, text) |
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.
minor: You could use more descriptive aliases, maybe match and fenced_match? (just to improve readability)
67ebf26
to
a9e8d18
Compare
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.
@Ezio-Sarthak This looks really useful: it works and that first commit looks like it does fix that issue without an obvious drawback?
zulipterminal/config/regexes.py
Outdated
# (*) Example text: #**stream name>Topic name | ||
REGEX_AUTOCOMPLETE_STREAM_TOPIC = r"#\*\*([^*>]+)>([^*]*)$" |
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.
I would add this to the next commit, but use this commit as a refactor of at least some other regexes, particularly those where the content of the regex is not as critical to understand in the subsequent code.
This constant is not different from in @prah23's feedback?
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.
Ah yes. Adding small understandable regexes and integrating them would be more apt. 👍
Re your latter point, I think Hari was referring to the local variable renaming, particularly, m_fenced
to match_fenced
that are used in the next commit.
tests/ui_tools/test_boxes.py
Outdated
# Fenced prefix | ||
("#**Stream 1**>T", 0, "#**Stream 1>Topic 1**", True), |
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.
For reference, the web app also supports #**Stream 1** >
, presumably for the stream complete generating a space after it?
I think this could be an extra feature on top, depending how straightforward it is, since we don't add a space.
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.
Yeah. I just quickly tested some autocompletes in the web app. All of them added a space in the end. For us, that might be a future normal, I think :)
191e664
to
449066e
Compare
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.
@Ezio-Sarthak The refactor makes this cleaner and close to merging 👍
As per inline, we don't need to add the regexes until we use them though.
We discussed the #streamname>
autocomplete being OK on the stream; could you file an issue or start a discussion regarding the space-after-completion point? Maybe there's discussion re the web app that's relevant?
# (*) Stream and topic regexes | ||
REGEX_STREAM_NAME = r"([^*>]+)" | ||
REGEX_TOPIC_NAME = r"([^*]*)" | ||
|
||
|
||
# (*) Example: #**zulip-terminal | ||
REGEX_STREAM_FENCED_HALF = r"#\*\*{stream}".format(stream=REGEX_STREAM_NAME) | ||
# (*) Example: #**zulip-terminal** | ||
REGEX_STREAM_FENCED = r"#\*\*{stream}\*\*".format(stream=REGEX_STREAM_NAME) |
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.
These are relevant only in the next commit(s) where they're first used?
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.
Some of these still seem to be present?
449066e
to
201a10a
Compare
c099dd1
to
980e94b
Compare
This small commit explicitly sets delimiter for msg_write_box, in order to support autocompletion of text with whitespaces, for both private and stream write boxes. Note that the delims specifed are default ones, except that whitespace is ignored, so as to make it function properly in autocompletes. The default completer delims for message compose are stored in the constant `DELIMS_MESSAGE_COMPOSE`. The commit also fixes a bug in which a user isn't able to use autocompletes for space-containing texts. Tests amended (comments) and added. The existing tests for space-containing prefixes are justified with this commit. Fixes zulip#925 as a side effect.
This commit adds a method that would process and return typeaheads for stream+topic prefixes. The current approach uses regex for identifying the last occurence of required format. The dedicated autocomplete function is: `autocomplete_stream_and_topic`. Note that the regex used for accessing stream and topic data is robust to the function, as the prefix would be manipulated to match this regex type, and then a call to this function would be made. See the next commit for more clarification. The stream and topic names regexes are inspired from webapp's static/js/compose_typeahead.js
980e94b
to
0232a26
Compare
This is the first implementation of stream+topic autocomplete in the message content box. This commit adds a validation helper that does the following things: * Checks if a given prefix string is a valid candidate for stream+topic autocomplete. * If the prefix validation is successful, the metadata, i.e, autocomplete map, prefix indices (to include the helper added in previous commit) and the prefix text are updated. Tests added for `autocomplete_stream_and_topic`, since it's the first commit where this function is invoked.
This commit extends support for stream+topic autocomplete from the previous commit to include the stream fences case: `#**stream name**>Topic name`. ^^ The current approach uses a regex for identifying the last occurrence of required format containing stream fences. The dedicated autocomplete function remains the same: `autocomplete_stream_and_topic`. Tests added.
This commit adds an enhancement to show typeaheads for stream+topic prefix string that don't have stream fences, e.g., #stream>topic. This would allow a user to avoid adding fences and just filling stream and/or topic name right away. Tests added. Ticks a checkbox in zulip#448.
0232a26
to
e4a0e59
Compare
@Ezio-Sarthak Thanks for getting this done and making the updates to this 👍 I've shifted the stream/topic regexes to the first commit they're used to hopefully make it clearer, made a few commit text adjustments and am merging now 🎉 |
The PR does the following tasks:
regexes.py
(commit 2-5)Ticks a check box in #448.