This brings support for code actions and source actions, along with some bug fixes
Also fixes `getAllMarkdownDocuments` to prefer open documents instead of those on disk
Fix markdown link diagnostics not updated when directories are renamed/deleted
Turns our that `createFileSystemWatcher` will not fire if a parent dir is renamed / deleted. See #60813
To fix this, I believe we have to create watchers for all parent directories too (or watch everything in the entire workspace)
* Add experimental support for update markdown links on file moves/renames
Fixes#148146
This adds a new experimental setting that automatically updates markdown
Note that this needs a new version of the vscode-markdown-languageservice so the build is expected to break for now
* Pick up new LS version
* Move MD diagnostics to language server
This switches us to using the LSP pull diagnostic model with a new version of the language service
* Bump package version
* Delete unused file
* Move smart select and folding to md language server
Also fixes a few minor issues:
- Don't log to web console
- Remove convert code since it is no longer needed
- Use correct extension id
* bump cache
* Bump package version
Co-authored-by: João Moreno <joao.moreno@microsoft.com>
* 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
* 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
- 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
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
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`
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`
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
* 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
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
* 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
* Improve markdown link regexp
This makes the markdown link regexp more readable and also combines the two regular expressions we were running
* Fixed backtracking
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
(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
* 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`
* Clean up markdown diagnostic tests
This splits the diagnostic compute tests from the test for the diagnostic manager
* Mark internal field as private
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
* 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
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
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`)
This updates the text editor drop proposal (#142990). This change introduces `DocumentDropEdit` which removes the need for `SnippetTextEdit`. This interface may also be extended in the future with additional metadata
* Iterate on paste edit provider api
For #30066
- Pass all selections to paste providers. For #151326
- Introduce `DocumentPasteEdit` as return type. This new type uses an `insertText` that is applied to every paste location (for multicursor), plus an optional additional edit
- Add `DocumentPasteProviderMetadata`. This lets extensions tell us which types of mimetypes they are interested in, letting us avoid round trips if no extensions care about the pasted data
* Correctly batch insertText
This change introduces a `ResoruceMap` map type that is essentially `Map<vscode.Uri, T>`
It also fixes a potential race condition with `MdWorkspaceCache` where two quick calls would both trigger init
For #30066
This adds a new `documentPaste` api proposal that lets extensions hook into copy and paste.
This can be used to do things such as:
- Create link when pasting an image
- Bring along imports when copy and pasting code
This change lets you ignore all links to a given file, even if those links include a header. For example: `[text](/path/to/file#some-header)` can be ignored using `/path/to/file`
This change renames the experimental skipPaths setting to ignoreLinks. This setting applies to all types of links, and can also be used to ignore links to headers
When reloading windows that need to restore a markdown preview, sometimes I'll see an error when the markdown preview tries accessing a disposed of webview. This seems to be cause caused by `provideTextDocumentContent`, where we end up disposing of the webview before an `await` resumes execution
For #121256
This change adds the current `ouputItem` to the notebook markdown renderer's environment
Renders that extend our markdown renderer can use this to access output item metadata for example
The new `markdown.experimental.validate.fileLinks.skipPaths` setting lets you specify a list of paths (as globs) that should not be validation
This is useful since markdown is used in a range of environments, and sometimes you may need to link to paths that don't exist on disk but will exist on deployment
A few other changes here:
- Adds a quick fix that adds paths to `skipPaths`
- Rename existing settings to use the `.enabled` prefix
For #146303
This PR updates the markdown diagnostic reporter to watch linked to files. If one of these linked to files is created or deleted, we recompute the diagnostics for all markdown files that linked to it
For markdown such as `<scope:tag>b</scope:tag>`, we currently detect `<scope:tag>` as an uri (an autolink) and then try validating it as a file path
This change doesn't fix `<scope:tag>` being detected as a link (which is actually correct if there isn't closing html), but does fix the us trying to validate it by marking the uri as external
Fixes#149406
Make sure that escaping the leading `[` of a reference link means it is not considered a link
- Picks up new grammar with fixes
- Updates our document link provider to also not consider these as link
We currently validate each link in a markdown file individually. This means that if there are multiple links to the same file, we check if that file exists multiple times
With this change, we instead will check that the file exists once and then use this to add diagnostics for all the links to it. This is done by introducing a new `FileLinkMap` which maps file paths to links within that file
This tracks inflight diagnostic computation and tries to cancel them if a new request comes in for the same document (usually because the document has changed or has been closed)
* Add experimental support for reading files in data transfer
Adds a new `DataTransfer.asFile` method which lets you get file objects from a `DataTransfer`. This is currently only hooked up for drop into editors.
A few follow ups:
- Right now the file data is also read eagerly when it is transfered to the extension host. Before shipping this we would make this happen lazily instead
- The drop into editor api does not provide a nice way to do anything with the dropped files.
We should at least support returning a `WorkspaceEdit`. However `WorkspaceEdit` only supports text files, so we would also need to add an API that lets it deal with binary files
* Make `asFile` return a value instead of a promise
`asFile().data()` already returns a promise so `asFile` doesn't also need to be async
* Trying resolving data files transfer lazily
* Cleaning up code for lazy drop
* Remove testing code
* Remove unneeded buffer serialize
* 💄
* Initial work on md link diagnostics
* Adding settings to enable/disable validation
* Add delay for recomputing diagnostics
* 💄
* Split test on diagnostics compute vs management
* Validate on file open
* Remove dianostics on file close
* Allow paths to folders
* Add validation configuration option
By changing output esbuild setting for Markdown preview scripts to iife,
prevents global namespace pollution and reduces possibility of breaking
the preview by contributions from other extensions.
- Use `vscode-languageserver-textdocument` instead of custom impl
- Reuse `InMemoryDocument` across tests and working code
- Use `SkinnyTextDocument` in more places
- Fixes some test errors that seem to be caused by bad `InMemoryDocument` impl
Revert "Revert e7fffbf1c9169087f1098aedfe54c59c079fa3ac"
This reverts commit 6786b0ad7d.
Two changes:
- Lazy import parcel/watcher
- Add `@parcel/watcher` as a dev dep in extensions folder so that we pull in correct version for build os
* add single reference linking regex
* add less invasive regex
* add lookahead to exclude [tag]: <url> case
* add tests for references when no [] exists
* revert integration test script
* make test description clearer
* remove vim swap file (whoops)
Co-authored-by: Jayce <grate.resales.0r@icloud.com>
Co-authored-by: Jefferson Chen <jc@Jeffersons-MBP.attlocal.net>
Fixes#138630
If the webview does not exist, we need to update the html on it instead of posting a message to it. This makes sure the correct content is shown when the webview is created again
This also removes a previous workaround for this issue that I no longer believe is required
* Prevent link highlight in markdown codeblocks (#139770)
* Handle inline codespan variants for markdown link provider (#139770)
* Refactor codespan detection in markdown link provider (#139770)
Fixes#123144
Uses the standard markdown renderer for `text/latex` outputs. This enables support for python outputs such as:
```python
%%latex
Given : $\pi = 3.14$ , $\alpha = \frac{3\pi}{4}\, rad$
```
For #140602
Only normal links for now. Will add reference links later. Should support the forms:
- `[](dir/file.md)`
- `[](./dir/file.md)`
- `[](/root-dir/file.md)`
- `[](#header)`
- `[](./dir/file.md#header)`