-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow empty input, consider it "now" #8
Conversation
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*($|.*)/); |
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.
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.
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 🙂
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.
Then I guess ^tsu?\s?(.*)
would be enough to handle that case
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.
Indeed, let me quickly adapt
} | ||
|
||
if (match) { | ||
const isUTC = term.startsWith('tsu'); | ||
const input = match[1]; | ||
|
||
if (input) { |
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 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)
And one more improvement, allow just typing
ts
ortsu
when I want to get thenow
- typingts now
is just too many characters 🙂Review this code ignoring whitespaces: link