Commit graph

828 commits

Author SHA1 Message Date
Logan Ramos a20329d291
Switch extensions to 1DS (#154299)
* Move extensions to 1DS

* Switch extensions to 1DS
2022-07-06 17:18:41 -07:00
Matt Bierner ad9675f099
Scaffold out basic markdown language server (#154293)
* Scaffold out basic markdown lsp

This scaffolds out a new markdown language server and then uses it to implement document symbols. After the change, the markdown extension will have the following structure:

- languageService — Where all the LSP language stuff will eventually land
- server — The actual language server. Consumes ` languageService`
- src — The current extension that launches the server and implements VS Code specific functions

* Adding build scripts

* a

* Use language service from github

* Remove ls build scripts

* Bump versions

* Only build ext

* Enable for web

* Fixing for browser
2022-07-06 16:03:24 -07:00
Matt Bierner f6271dd82e
Fix angle bracket path completions for link defs (#154182)
Fixes #153866
2022-07-05 11:55:20 -07:00
Matt Bierner fc0bd9d377
Remove reliance on document.lineAt (#154191)
* Remove reliance on document.lineAt

This helps aligning more with the LSP types: https://github.com/microsoft/vscode-languageserver-node/issues/146

* Strip newline
2022-07-05 11:52:47 -07:00
Matt Bierner 0b3574dcef
Update id of markdown-it renderer (#153876)
Fixes #153873
2022-06-30 23:19:49 +00:00
Matt Bierner e44361365e
Don't include reference links that are inside other links (#153864)
Fixes #150921
2022-06-30 15:43:31 -07:00
Matt Bierner bbce24d8bb
Handle fs error in markdown path completions (#153869)
Fixes #153867
2022-06-30 22:32:32 +00:00
Matt Bierner e13feea6ae
Only compute diagnostics for opened md files (#153395)
* Only compute diagnostics for opened md files

For #152494

* Make tests stable for result ordering
2022-06-27 15:55:38 -07:00
Matt Bierner fc709e2d35
Use more standard values for scheme constants (#153367)
This drops the `:` from the scheme constants as it was easy to misuse this
2022-06-27 22:35:17 +02:00
Matt Bierner da0f64881a
Dispose in markdown tests (#153345)
Updates the markdown tests to dispose of disposables created during the test
2022-06-27 15:52:59 -04:00
Matt Bierner d1b4630a50
Fix Markdown tests on windows (#153212)
Fix windows tests
2022-06-25 18:59:25 +02:00
Matt Bierner 3b549009fe
Markdown path completions tests use mocked out fs (#153045)
* Markdown path completions tests use mocked out fs

This updates the path completion tests to stop depending on the actual fs and instead use `IMdWorkspace`

* Update remaining tests
2022-06-24 23:01:24 +00:00
Matt Bierner 64305a732e
Better handling of text/uri-list in built-in extensions (#153163)
- When splitting `text/uri-list`, we should split on `\n` to handle against spec versions of `text/uri-list`
- However when constructing a `text/uri-list`, we should use `\r\n` to align with the spec
2022-06-24 15:24:16 -07:00
Matt Bierner 7fd834b64f
Enable angle bracket path completions in markdown (#153158)
Fixes #152510
2022-06-24 15:04:40 -07:00
Matt Bierner 8acfd0ae60
Exclude empty links from md results (#153161)
These are technically valid links but we don't care about them since they take up no space
2022-06-24 21:42:00 +00:00
Matt Bierner 00ad6bc3d4
Markdown document links should reveal cell in notebook (#153147)
Fixes #141024
2022-06-24 15:49:15 -04:00
Matt Bierner d6497d3db1
Use ResourceMap (#153051)
Replaces `Set` of uris with a `ResourceMap`
2022-06-24 01:00:05 +00:00
Matt Bierner 9b7696cc9c
Fix notebook links to other docs in edited markdown cells (#153052)
Fixes #148199

This makes us resolve links in notebooks relative to the notebook document instead of relaitve to the cell
2022-06-23 20:55:08 -04:00
Matt Bierner ab7bc9fb0b
Split up MD link tests (#153048)
This splits the markdown link tests in two:

- Tests for detecting links in md files (`MdLinkComputer`)
- Tests for the actual vs code editor link provider

Also fixes a few cases splitting these tests up caught
2022-06-23 17:53:56 -07:00
Logan Ramos 4a7a6a597a
Update extension telemetry modules (#153057) 2022-06-24 00:53:23 +00:00
Matt Bierner 385bf5036b
Optimize NoLinkRanges lookup (#153010)
This switches us to use a map to check if a position exists inside the no link ranges
2022-06-23 11:38:13 -07:00
Matt Bierner 07144d22c4
Rename types in the markdown extension (#152905)
Renames in the markdown extension

This renames some types and splits up some files as part of an exploration towards a proper LSP. Changes:

- `SkinnyTextDocument` -> `ITextDocument`
- Moved `ITextDocument` to own file
- `MdWorkspaceContents` -> `IMdWorkspace`
2022-06-22 14:12:48 -07:00
Matt Bierner be1ee5d9f1
Re-validate md files when a linked to file is created or deleted (#152520) 2022-06-22 19:02:46 +00:00
Matt Bierner 321423db2b
Standardize text/uri-list handling (#152756)
This creates a common set of functions for creating and parsing the `text/uri-list` mime type. As part of this, I also aligned us with the standard, which uses `\r\n` between lines instead of just `\n`
2022-06-22 13:53:37 +02:00
Matt Bierner 5437480941
Enable md paste actions by default (#152810)
Turns on pasting of links for easier testing. However `editor.experimental.pasteActions.enabled` is still off by default so this won't be enabled by default
2022-06-22 08:19:52 +02:00
Matt Bierner c84655d123
Reduce recomputation of state in markdown extension (#152804)
* Reduce recomputation of state in markdown extension

- Use `getForDocument` more often to avoid refetching documents
- Debounce `MdTableOfContentsWatcher`. We don't want this to trigger on every keystroke :)

* Cache LinkDefinitionSet

* Add test file change

* Fix toc watcher for tests
2022-06-21 16:25:10 -07:00
Matt Bierner 389aa8a935
Fix MdDocumentInfoCache computing values twice (#152799)
* Fix MdDocumentInfoCache computing values twice

Fixes a race where values could be computed twice before being cached

* Remove only
2022-06-21 16:22:07 -07:00
Matt Bierner d5a75f2ceb
Add logging for MD language features (#152792)
This verbose logging will help track down inefficient calling patterns (such as recomputing stuff)
2022-06-21 14:18:36 -07:00
Matt Bierner bbe7b54cf4
Remove custom editor tests (#152777)
These tests are not actively being run or maintained. Removing them for now
2022-06-21 15:37:19 -04:00
Matt Bierner fa53aa6fec
Cleanup pass for md extension (#152760)
Clean up names in md extension
2022-06-21 15:36:32 -04:00
Matt Bierner 2249b171f4
Reduce number of times MD docs are re-tokenized (#152674)
This change reduces the number of times we retokenize a markdown file by doing the following:

- Use `MdTableOfContentsProvider` in more places
- Introduce a `IMarkdownParser` interface that lets us drop in a caching version of the tokenizer
2022-06-21 08:43:01 +02:00
Matt Bierner 369252a027
Skip diagnostics for non-open md files (#152687)
Currently we only show diagnostics for opened tabs. This means we shouldn't waste time computing diagnostics for these non open files
2022-06-20 16:39:01 -07:00
Matt Bierner 0bc3109761
Don't try parsing non-markdown files (#152661)
This fixes our references and rename provider to not try parsing non-markdown files as if they were markdown
2022-06-20 10:44:50 -07:00
Matt Bierner 4c72dedb4a
Optimize markdown workspace scanning (#152563)
* Optimize markdown workspace scanning

- Adds cache for markdown file
- Avoid reading non-markdown files from disk (when we expect markdown files)
- Use `range.contains(pos)` instead of `range.intersects(range)`

* Don't remove cached document on change

We only want to invalidate the cached document when it is first opened (since the cached version is the one from disk). Otherwise we can use the live version of the doc
2022-06-19 09:40:10 -07:00
Matt Bierner 5a175207de
Improve markdown link regexp (#152533)
* Improve markdown link regexp

This makes the markdown link regexp more readable and also combines the two regular expressions we were running

* Fixed backtracking
2022-06-19 06:25:54 +02:00
Matt Bierner 78597fd026
Don't hardcode use of github slugifier (#152507)
Use `engine.slugifier` for this instead
2022-06-17 17:25:54 -04:00
Matt Bierner dea813ff7c
Add table of contents provider abstraction (#152504)
We currently re-compute the same table of contents for markdown files multiple times. This is because multiple language features all need table of contents

With this change, we introduce a new `TableOfContentsProvider` which maintains a cache of the table of contents per file. This provider is then passed into every caller that needs a toc
2022-06-17 18:20:02 +00:00
Matt Bierner 623f55f437
Refactor markdown language features (#152402)
(sorry for the size of this PR)

This change cleans up the markdown language features by making the following changes:

- Use `registerXSupport` public functions to register these
- Expose the slugifier the `MarkdownEngine` uses. You never want to use a different one if you already have a markdown engine
- Sort of clean up names. I'd introduced a bunch of confusing names while iterating in this space. What I'm working towards:

    - `Computer` — Stateless thing that computer data
    - `Provider` — Potentially stateful thing that provides data (which may be cached)
    - `VsCodeProvider` — The actual implementation of the various vscode language features (which should only be used by VS Code and in tests, not shared with other features)
- Introduce `MdLinkProvider` to avoid recomputing links for a given document. Also use this to hide more internals of link computation
2022-06-17 10:25:52 +02:00
Matt Bierner afe316c08c
Add diagnostic manager enablement change tests (#152392)
* Add test for MD diagnostic manager config changes

Add a simple test the enabling/disable diagnostics should make the diagnostic manager recompute diagnostics

* Add `.get`
2022-06-16 15:53:19 -07:00
Matt Bierner cb5fa75d11
Clean up markdown diagnostic tests (#152374)
* Clean up markdown diagnostic tests

This splits the diagnostic compute tests from the test for the diagnostic manager

* Mark internal field as private
2022-06-16 22:33:11 +02:00
Matt Bierner 3114ee690b
Split out VS Code reference provider from markdown reference provider (#152369)
This change renames the main markdown reference provider class to `MdReferenceComputer` and then uses this to implement a `vscode.ReferenceProvider`

This more cleanly splits the VS Code part of the logic from the general reference calculation stuff other providers consume
2022-06-16 15:47:48 -04:00
Matt Bierner 6c252851f2
Revalidate linked files on header change (#152366)
Fixes #150945

With this change, when the headers in a file change, we should also try to revalidate all files that link to it
2022-06-16 18:14:01 +00:00
Matt Bierner 4fc5d76213
Fix ranges and validation setting for MD own path + header links (#152270)
* Fix ranges and validation setting for MD own path + header links

Previously for a `file.md`, links to headers in that file that use paths, such as `[link](./file.md#some-header)` were validated using `markdown.experimental.validate.fragmentLinks.enabled`

This is confusing as that setting was only meant to be used for links such as`[link](#some-header`). It also resulted in the diagnostic having the incorrect range

This change instead makes these links be validated by `markdown.experimental.validate.fileLinks.markdownFragmentLinks`

* Fix compile
2022-06-15 20:02:41 -07:00
Matt Bierner a765abcf07
Adopt ResourceMap for MD diagnostics (#152264)
Adopt ResourceMap

Switches to use `ResourceMap` instead of our own implementation
2022-06-15 15:43:09 -07:00
Matt Bierner f17b33faf2
Use .?method() in more places (#152112)
Switches simple patterns like:

```ts
if (some.thing) {
    some.thing.method();
}
```

to:

```ts
some.thing?.method()
```

This is more concise and avoids having to repeat the `some.thing` part
2022-06-15 16:28:31 +00:00
Matt Bierner 354e1a0595
Finalize data file reading API (#152127)
Fixes #147481
Also reverts #150963 since the `kind` field is not being finalized
2022-06-15 07:56:02 -07:00
Matt Bierner 00273730e8
Split markdown linkComputer from linkProvider (#152124)
Instead of passing around a full `vscode.DocumentLinkProvider`, we should pass just the more minimal interface that consumers need
2022-06-14 15:34:05 -07:00
Matt Bierner 00574df08a
Remove extra path field in FileLinksData (#152004)
Remove extra `path` field

This field is no longer needed after we switched to use `ResourceMap` vs `Map`

Also inlines the `FileLinksData` type def
2022-06-14 08:01:53 -07:00
Matt Bierner a658c04b0a
Adjust md external header link diagnostic range (#152001)
Fixes #151998

Makes errors for invalid headers on file links only cover the fragment range instead of the entire link range
2022-06-14 09:39:49 +02:00
Matt Bierner 1a07fd15d7
Clarify markdown validate settings (#151997)
Clairify markdown validate settings

Fixes #150949

- Rename headerLinks -> fragmentLinks
- Add new `fileLink.markdownFragmentsLinks` to validate the headers on fragment links (inherits the default setting value from `fragmentLinks`)
2022-06-13 17:06:28 -07:00