Skip to content
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

Allow empty input, consider it "now" #8

Merged
merged 2 commits into from
Nov 2, 2017

Conversation

maximbaz
Copy link
Contributor

@maximbaz maximbaz commented Oct 26, 2017

And one more improvement, allow just typing ts or tsu when I want to get the now - typing ts now is just too many characters 🙂

Review this code ignoring whitespaces: link

image

@maximbaz maximbaz mentioned this pull request Oct 26, 2017
@maximbaz
Copy link
Contributor Author

maximbaz commented Nov 2, 2017

A friendly ping @benoitzohar 🙂

src/index.js Outdated
@@ -15,73 15,71 @@ const plugin = ({ term, display, actions }) => {

//fall back on the ts prefix
if (!match) {
match = term.match(/^tsu?\s(.*)/);
match = term.match(/^tsu?\s*($|.*)/);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you changed the regex?
I'm under the impression that the first * will catch everything, so the change after it won't affect anything.

screenshot 2017-11-02 09 04 09

screenshot 2017-11-02 09 04 19

Copy link
Contributor Author

@maximbaz maximbaz Nov 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - the old regex requires at least one space, i.e. ts_, the new regex works with plain ts - I simply thought it would be neater 🙂

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess ^tsu?\s?(.*) would be enough to handle that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, let me quickly adapt

}

if (match) {
const isUTC = term.startsWith('tsu');
const input = match[1];

if (input) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me this would be enough to achieve what you want (which I wanted to do in the first place, don't know why I forgot to test it)

@benoitzohar benoitzohar merged commit 0eae444 into benoitzohar:master Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants