extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[Unicode Symbols Search] find super script with number input

Open lukasoppermann opened this issue 2 years ago • 6 comments

Extension – Unicode Symbols Search

Author: @mmazzarolo

I would love to be able to get a superscript number by entering something like super 9 -> ⁹

Describe the feature and the current behavior/state. Currently it does not find the superscript item when I enter super 9. I have to type super nine.

It would be easier to use if it could just work with both, the numeric (9) value and the word (9). Same should work for subscript.

Who will benefit with this feature? Anybody using this to get super script numbers or subscript.

lukasoppermann avatar Jul 12 '22 10:07 lukasoppermann

@mmazzarolo fyi

danielsequeira avatar Jul 12 '22 14:07 danielsequeira

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Aug 31 '22 20:08 stale[bot]

Hey @mmazzarolo @danielsequeira I think all that is required is to add the number to the name in the dataset json file: https://github.com/raycast/extensions/blob/d18a6e43408d105a3ed7a17b6693fca19ea75ea3/extensions/unicode-symbols/assets/dataset.json#L4803

Happy to send a PR if it will be merged.

lukasoppermann avatar Sep 01 '22 06:09 lukasoppermann

@lukasoppermann to be honest I think it would be better to start support aliases for such use cases. The name property is a strict mapping to the official unicode character name; if we start editing the some of them just because we don't like them, that might bite us back in the future (just my 2c!). What do you think @lukasoppermann ?
Would be happy to review and help shipping an aliasing feature btw!

(Sorry for the late reply, I didn't notice I was pinged twice 😓 )

mmazzarolo avatar Sep 01 '22 07:09 mmazzarolo

@mmazzarolo That is even better. How would we go about adding this though?

lukasoppermann avatar Sep 01 '22 07:09 lukasoppermann

@mmazzarolo That is even better. How would we go about adding this though?

OK, I started writing something and then I changed my mind 😬

Easiest way to implement this

  • In the generate-dataset.ts script, add a something something like const charCodeToAliases = {"8313": ["superscript 9"]}. This will be the list of aliases we want to apply to the final dataset. I think it might even be better to define it in its own json file.
  • Update mapCharacterToDatasetItem to also add the aliases to the output (if any).
  • In the src/dataset-manager.ts, update the Fuse search to also search in aliases (just add it to the key array).

I think this is the easiest (and most performant) way to implement this.

Drawback of this approach:

  • Adding an alias requires re-running the generate-dataset.ts script.
  • It would be cool if users could add their own alias for a character as a preference, but I think it might be a bit hard to do with the current setup.

Let me know if it makes sense!

Previous idea (just for historical context):

It's been a while since I worked on this extension, but if I recall correctly the idea I had around character aliasing was:

Reason about some of the decisions above:

  • We could also merge the aliases with the dataset values using the generate-dataset.ts script. While more "elegant", I think this is less ergonomic because it requires running that script every time we add new aliases to the repo.
  • There might be a way to use Fuse to also handle the aliases search as well (instead of doing that search manually like I suggested), but we need to ensure we don't low the performance → AT THIS POINT I REALIZED THAT IT DOESN'T SEEM TO BE POSSIBLE TO GRAB CHARS BY ALIASES WITH THIS SETUP UNLESS WE FILTER THE ENTIRE DATASET WITHOUT USING FUZE. /STOP-SCREAMING

mmazzarolo avatar Sep 01 '22 09:09 mmazzarolo

I might have time to work on this next weekend. Would it be possible to add generate-dataset to the build script so that the fact that "it requires running that script every time we add new aliases to the repo" doesn't become a pain point? I think merging aliases is the only way for this command to remain performant.

Sheraff avatar Sep 19 '22 16:09 Sheraff

@Sheraff I think so? I think I did find some issues doing that in the past but I don't remember what they were... and things might have changed now 👍

mmazzarolo avatar Sep 20 '22 08:09 mmazzarolo

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Nov 09 '22 09:11 stale[bot]

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean 😊

stale[bot] avatar Nov 24 '22 05:11 stale[bot]

I'm closing this 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.

stale[bot] avatar Dec 02 '22 05:12 stale[bot]