-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 strlen extension #16675
Add strlen extension #16675
Conversation
- wip - feat: Create \'strlen\' plugin to display clipboard string length
Congratulations on your new Raycast extension! 🚀 You can expect an initial review within five business days. Once the PR is approved and merged, the extension will be available on our Store. |
I think you should use https://github.com/sindresorhus/string-length to calculate the correct length. Also, it's better to add https://github.com/sindresorhus/string-width for calculating width. |
Hm, might be nice for a second and third field. |
- eslint fix - add other length + width
|
||
useEffect(() => { | ||
if (!input) { | ||
Clipboard.read().then(({ text }) => setInput(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.
It's better not to read the user's clipboard. You can add a preference option to let the user enable this feature manually.
|
||
return ( | ||
<List | ||
onSearchTextChange={(value) => setInput(value)} |
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.
Don't setInput
from here. You will get a repeated text while pasting.
{String(input).length !== stringLength(input) && ( | ||
<List.Item | ||
key={"length-corrected"} | ||
icon={{ source: Icon.Hashtag, tintColor: Color.Magenta }} | ||
title={"Length (Corrected)"} | ||
subtitle={{ | ||
value: stringLength(input).toString(), | ||
tooltip: | ||
"This string might contain astral symbols. This length reflects the string length with ansi escape codes ignored.", | ||
}} | ||
/> | ||
)} | ||
{String(input).length !== stringWidth(input) && ( | ||
<List.Item | ||
key={"width"} | ||
icon={{ source: Icon.Hashtag, tintColor: Color.Magenta }} | ||
title={"Width"} | ||
subtitle={{ | ||
value: stringWidth(input).toString(), | ||
tooltip: | ||
"The width of this string differs from its length due to special characters.", | ||
}} | ||
/> | ||
)} |
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.
You can always show the result of string-length
and string-width
since they are under different calculation logics.
You can also provide the library link to users to let know why we have three results.
Yea but not all strings I want to check are on the clipboard. Plus, |
What about Toolbox? We might be able to make some support for making quicklinks for a specific view 😊 |
Why the urge to bundle this into another extension? I think the Linux philosophy of ‘one tool one job’ is still the best. |
It's because our store is massive and we're trying not to add too many with the same purpose I also found this extension in the store which seems to be what you're looking for with extra options too 🙂 |
This pull request has been automatically marked as stale because it did not have any recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊 |
This issue has been automatically closed due to inactivity. Feel free to comment in the thread when you're ready to continue working on it 🙂 You can also catch us in Slack if you want to discuss this. |
Description
This extension shows the length of a string.
Screencast
Checklist
npm run build
and tested this distribution build in Raycastassets
folder are used by the extension itselfREADME
are placed outside of themetadata
folder