skip to Main Content

I find that vscode does really good url extraction, better than any methods found in the internet. Since vscode is opensource, where can I find the code? Probably regex rules. shortcut for nice url extraction result

I searched the source code with keyword "url" or "extract", but can not find any clues.

2

Answers


  1. vscode uses ripgrep under the hood. You can find more information about the implementation here https://github.com/BurntSushi/ripgrep

    Login or Signup to reply.
  2. For the builtin link detection

    Not 100% percent sure that this is it, but from my search through the source code, I think you might be looking for src/vs/editor/common/languages/linkComputer.ts, which uses a state-machine-based approach.

    You can see in src/vs/editor/browser/services/editorWorkerService.ts, in EditorWorkerService‘s constructor, there’s a comment saying "register default link-provider and default completions-provider", and a call to client.computeLinks, which is defined in src/vs/editor/common/services/editorSimpleWorker.ts in the EditorSimpleWorker class’ computeLinks function, which in turn calls computeLinks from linkComputer.ts. That comment lines up nicely with the description of DocumentLinkProvider<T>‘s provideDocumentLinks function, which states:

    Note that the editor ships with a default provider that detects http(s) and file links.

    Fun fact: you can find where it’s used in https://github.com/search?q=repo%3Amicrosoft%2Fvscode%20computeLinks&type=code, including src/vs/workbench/contrib/output/common/outputLinkComputer.ts and src/vs/workbench/contrib/terminalContrib/links/browser/terminalUriLinkDetector.ts.

    For extension-contributed link "detection"

    As mentioned above, there’s the DocumentLinkProvider extension API that extension can use to contribute links to documents. If you want to find out how a specific extension is doing that, you’ll need to post a question specifically about that extension.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search