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

Feat: RegEx in keywords #152

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

vonEdfa
Copy link

@vonEdfa vonEdfa commented Jun 4, 2019

Added the functionality to use a proper RegEx pattern for each keyword instead of simply relying on the text field.

In detail:

  • Added the "regex" object to "keywords" settings. Currently only includes the "pattern" key. If this option exists we will use the "regex.pattern" instead of the "text" field when creating the extension's search pattern.
  • Altered the way that the matches are grouped to allow the existing code to recognize the new behavior.
  • Altered the way that the extension's search pattern is created to allow each keyword to have it's own match group in the search results.

Additional changes:

  • Updated the Readme to include examples of the added feature.
  • Added tests for a few of the util functions I am using or created.
  • Fixed the typo in the variable name 'mathes'.
  • Removed an unused variable in a forEach loop.

Malin von Matern added 10 commits May 29, 2019 23:06
+ Added keyword option: useRegex. Updated init to use the new setting.
* Rearranged functionality in updateDecorations to allow for multiple matches for a single decoration type
* Ditched the double for loop in favor of regex groups (the code can still be cleaned up further, though)
* Added some supporting functionality for handling regex groups and making sure we only get one group per keyword
* Renamed settings variable :-)
* Removed unused parameter from one of the util functions
* Merged some code that did basically the same thing
* Rearranged the setting so it now is an object named "regex" which the pattern to use as its child. Makes the logic of the code easier to handle, imho :)
+ Added tests for util functions:
   - excapeRegExp
   - escapeRegExpGroups
* Modified test launch settings to not include any other extensions.
* Updated readme with example of the regex setting
* Improved the legacy version of escapeRegExpGroups and gave it its own exported function
@CanRau
Copy link

CanRau commented Feb 19, 2020

Ooh that would be super helpful 👏

Use case
I'd like, I think, to only match // TODO and * TODO so single line and block comments.. more or less^^
Otherwise I had to many false positives already.

@agutenkunst
Copy link

Would love the feature! Please merge and release!

@WybeBosch
Copy link

Since this repo(wayou/vscode-todo-highlight) has not been updated since 2018, im not gonna wait for him to merge this amazing feature, il just swap to your version instead ;)

@CanRau
Copy link

CanRau commented Jul 2, 2020

@WybeBosch what version are you switching to?
The one of this PR or did I miss anything? 🤔

@WybeBosch
Copy link

@WybeBosch what version are you switching to?
The one of this PR or did I miss anything? 🤔

Someone created a Fix so you could use regex, and they put in a Pull request with the Original Author. But the original author has not updated the extension since 2018, so its safe to say he will never implement the Fix made by this other user.

However, you can just Download the extension with the Fix by the other user, by grabbing the contents of this repo while being inside this Pull request.

Go to this link, and it should download a zip file. Replace the original extension files with the contents of this zip file and voila!
https://api.github.com/repos/wayou/vscode-todo-highlight/zipball/pull/152/head

@CanRau
Copy link

CanRau commented Jul 2, 2020

@WybeBosch cool thanks for instructions 🙏

@jgclark
Copy link

jgclark commented Jul 7, 2020

@vonEdfa many thanks for your improvements. I got them working for me, as @WybeBosch directed, but very few are going to find this. So I thought I'd try and learn how to do a full release, building on your work -- unless you've already done that?

The original documentation has confused me about the JSON settings in places, but I'm not fluent in JavaScript, and so can't tell from the source what the documentation should say. As you understand the code, could you please advise me?

  1. does todohighlight.keywordsPattern still now have an effect, and does it still override the .keywords setting?
  2. in the given example that starts
"todohighlight.keywords": [
  "DEBUG:",
  "REVIEW:",
  {
    "text": "NOTE",
    "color": "white",

are the settings for REVIEW: supposed to apply to DEBUG: as well? If not, what happens with the DEBUG:?
3. In that example, what are the REVIEW: and DEBUG: just acting as labels in the JSON? I can't see how their contents influences what's shown when it runs.
4. Is it right that the built-in FIXME: and TODO: patterns can't be turned off, but only their style overridden?

Thanks in advance.

@jeffery9
Copy link

so @jgclark should clear issues in this repo? 💯

@jgclark
Copy link

jgclark commented Jul 23, 2020

I would if I could @jeffery9. But I have no rights in this repo, and it seems the maintainer has abandoned it.

However, the good news is that I've now forked this extension into a new repo at https://github.com/jgclark/vscode-todo-highlight, and made available on the Marketplace. It includes better documentation, more examples, update for remote development, addition of regex per highlight etc.
You'll need to uninstall this extension and then install the new one from the marketplace, TODO Highlight v2.

@vonEdfa
Copy link
Author

vonEdfa commented Sep 22, 2020

Hey @jgclark sorry I've been slow replying! My memory is definitely not up to snuff with this repo anymore (but javascipt is my main language) but it sounds like you got it working without my input?
Haven't checked out your re-release yet but I sure will! I never created one myself (even though I played with the idea) since I'm a bad maintainer and I would most probably forget about the project just like the original author seemingly did.

@jgclark
Copy link

jgclark commented Sep 22, 2020

@vonEdfa nice to hear from you. I hope the new release of extension works well for you. I'm sure there might be some improvements you can continue to make, as you seem to know JS well, and I don't.

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.

6 participants