CommentLinks icon indicating copy to clipboard operation
CommentLinks copied to clipboard

Feature request: support for regular expression

Open sriediger opened this issue 3 years ago • 7 comments

Use case: I have changes.txt file in my solutions, which contains lines with a specific pattern XYZ-#### inside (e.g. XYZ-123). Clicking on it should open a website https://example.com/browse/XYZ-123

To support this, it would require to detect regex patterns e.g. (XYZ-[0-9]+)\b and then open the replacement link https://example.com/\1

I know Visual Assist has something like this, but it does not work for txt files.

It would be great if you could consider this feature request. Thank you very much in advance. best, Stefan

sriediger avatar Jan 20 '22 08:01 sriediger

That's a nice idea.

I have a similar thing where I create TODO comments that include an issue id. (e.g. TODO: See issue #123) and it would be nice to be able to turn them into clickable links too.

Some related thoughts/questions:

  • Do these need to be detected anywhere in a document or only in the equivalent of comments and after appropriate "link" text?
  • Might it be necessary to have a different configuration for each project (or solution)? so that different projects can use a different RegEx and/or base URI
  • Does it make sense to combine this new functionality into this extension, or put it in a new one?

mrlacey avatar Jan 20 '22 12:01 mrlacey

For reference, the related functionality in Visual Assist appears to be this: https://www.wholetomato.com/features/feature-source-links

mrlacey avatar Jan 20 '22 12:01 mrlacey

  • Do these need to be detected anywhere in a document or only in the equivalent of comments and after appropriate "link" text? Yes, that would be good, because I can't modify the existing changes.txt and these references could be anywhere. But they always have the same format XYZ-###.
  • Might it be necessary to have a different configuration for each project (or solution)? so that different projects can use a different RegEx and/or base URI That is not really clear, per solution could make sense, or having a list of regular expressions with a different
  • Does it make sense to combine this new functionality into this extension, or put it in a new one? New one would also be OK

sriediger avatar Jan 20 '22 13:01 sriediger

For reference, the related functionality in Visual Assist appears to be this: https://www.wholetomato.com/features/feature-source-links

The Source links of Visual Assist is exactly how it should work. And in Code it does. But I have raised a feature request to also support txt files some years ago. Unfortunately I did not get a response. But I can re raise the question in Visual Assist.

sriediger avatar Jan 20 '22 13:01 sriediger

Now you've suggested this, I want it for my use too. I just need to work out how. ;)

mrlacey avatar Jan 20 '22 13:01 mrlacey

  • Might it be necessary to have a different configuration for each project (or solution)? so that different projects can use a different RegEx and/or base URI

This might serve as a future enchantment. It might be enough to start with a single configurable option for the extension and then later add support for per solution/project configuration if/when needed.

Note. that much of this is for my own reference and documenting here so I don't forget 😉

mrlacey avatar Jan 20 '22 13:01 mrlacey

Could be handy to have a commentlink.config file or something that could specify these patterns for a repo and be checked in.

michael-hawker avatar May 11 '22 19:05 michael-hawker