Commit Graph

778 Commits

Author SHA1 Message Date
Johannes
0656d21d11 auto-fixed prefer-const violation 2022-06-08 17:49:21 +02:00
Matt Bierner
1327d1eb50 Adopt ResourceMap in more places (#151475)
This changes switches to use the new `ResourceMap` type in more places in the markdown extension where we need to have a map/set with uris as the key
2022-06-08 08:34:06 +02:00
Matt Bierner
60a68d666d Add resourceMap helper for markdown extension (#151471)
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
2022-06-07 18:00:10 -07:00
Matt Bierner
9545af80f6 Fix markdown link detection for links with titles (#151459)
Fixes #151458
2022-06-07 20:58:29 +00:00
Justin Chen
bcc7ffae3e bugfix on markdown underlines, addressing part of issue #136073 (#151178)
Co-authored-by: Justin Chen <t-justinchen@microsoft.com>
Co-authored-by: Matt Bierner <matb@microsoft.com>
2022-06-06 17:35:41 +00:00
Matt Bierner
9302343e8e Also ignore star checkboxes (#151029)
Fixes #150672

This makes our md link detection also ignore checkboxes like `* [x]` instead of just `- [x]`
2022-06-01 21:23:29 +00:00
Matt Bierner
7477efd87e Better message for markdown reference links (#151018)
Fixes #151017

Also improves the diagnostic message for invalid reference links to make it clear we are talking about a missing link definition
2022-06-01 19:01:36 +00:00
Matt Bierner
e6fff5ecff Don't parse checkboxes are links in markdown (#150914)
Fixes #150672
2022-05-31 14:57:32 -07:00
Matt Bierner
e4f7f6a9da Add PasteEditProvider (#107283)
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
2022-05-25 12:27:58 +02:00
Matt Bierner
1c7991f1e8 Markdown ignoreLink should apply to paths in header links (#150223)
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`
2022-05-23 17:07:15 -07:00
Matt Bierner
96cae45ba9 Rename skipPaths to ignoreLinks (#150064)
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
2022-05-20 22:54:21 +00:00
Matt Bierner
993c36c920 Fix markdown ext errors accessing disposed webview (#149960)
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
2022-05-20 09:17:57 -07:00
Matt Bierner
27903c28aa Remove unfinished test (#149864)
Mistakenly checked this in
2022-05-18 16:01:28 -07:00
Matt Bierner
daf0d5e551 Add skipPaths option for markdown link validation (#149859)
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
2022-05-18 14:37:08 -07:00
Matt Bierner
1c7ab35761 Rename to DocumentOnDropEditProvider (#149730)
This change renames `DocumentOnDropProvider` to `DocumentOnDropEditProvider`. This new name aligns with the existing `DocumentFormattingEditProvider`
2022-05-17 09:26:54 -07:00
Matt Bierner
c2b064538b Don't detect links in markdown code blocks (#149680)
Fixes #149678
2022-05-16 17:35:16 -07:00
Matt Bierner
d71f6ec0d9 Update markdown diagnostics when linked files change (#149672)
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
2022-05-16 17:30:39 -07:00
Matt Bierner
dd9dca9825 Fixing some html tags detected as autolinks for diagnostics (#149511)
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
2022-05-16 12:19:29 +02:00
Matt Bierner
113287ccc3 Don't treat escaped markdown reference links as links (#149407)
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
2022-05-12 19:35:36 -07:00
Matt Bierner
a075453e55 Clean up the markdown document link provider tests (#149405)
- Use `joinLines` instead of
- Inline document text
- Always use `example.com`
- Move issue numbers into test titles
- Clean up text
2022-05-12 16:01:51 -07:00
Matt Bierner
5485b8e215 Include " and '/' as puctuators for slugify (#149404)
We already include `'` and `/` makes sense to treat as a puctuator too for titles such as `# do A / B`
2022-05-12 15:56:25 -07:00
Matt Bierner
9e42783398 Don't repeat markdown link validation (#149169)
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
2022-05-10 09:14:40 -07:00
Matt Bierner
d850919250 Adds cancellation to md diagnostic computer (#149122)
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)
2022-05-09 15:42:32 -07:00
Matt Bierner
a6dd083a7e Use / for md paths, even on windows (#149120)
Fixes #149010
2022-05-09 15:22:44 -07:00
Matt Bierner
c08941b87c Ignore bulkedit previews for markdown references / renames (#148744)
Makes sure we don't pick up the fake documents created by the bulkedit-preview
2022-05-04 16:03:35 -07:00
Matt Bierner
9dab79d9c8 Fix markdown web extensions (#148739)
We're currently importing a file from `test/util`, which is not supported on web. Move the noop cancellation token into the `util` folder instead
2022-05-04 14:02:38 -07:00
Matt Bierner
93fd393a0e Add API proposal for reading files in data transfer (#148596)
* 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

* 💄
2022-05-04 12:59:27 -07:00
Matt Bierner
eba8ef0547 Add diagnostics for markdown links (#148578)
* 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
2022-05-02 16:06:00 -07:00
Jean Pierre
44e644467d Enable go to definition for markdown links (#148017)
* Enable go to definition for markdown links

* Add markdown definitionProvider tests
2022-05-02 10:07:40 -07:00
Matt Bierner
892d6ec2a2 Fix md workspace cache for untitled files
Makes sure we also add all text documents to the list of md docs
2022-04-30 20:15:40 -04:00
Matt Bierner
8449a9f5cb Fix md rename when file does not exist
Fixes #148147

- Don't try renaming non-existent files
- Also fixes a bug where renaming in untitled files would insert `untitled:`
2022-04-30 19:52:44 -04:00
Matt Bierner
3e182633c7 Adding some more tests for markdown references 2022-04-30 19:14:03 -04:00
Matt Bierner
c41728c479 Fixes #147896 (#148101)
* Fixes #147896

* Replace all

* Fix windows slash check

* Skip test on windows for now
2022-04-26 15:45:15 -04:00
Benjamin Pasero
72b4be55fa skip markdown rename tests (#147896) 2022-04-22 08:07:49 +02:00
Matt Bierner
59b6227bf3 Use un-encoded file paths are rename placeholder 2022-04-21 22:23:53 -04:00
Matt Bierner
7b1168660a Fix resolving of links on rename
We should resolve relative to the file the rename is triggered in
2022-04-21 22:23:53 -04:00
Matt Bierner
62eebab685 Use uri instead of string 2022-04-21 22:23:52 -04:00
Matt Bierner
b438e8438d Fixing rename to use correct file paths relative to containing files 2022-04-21 22:23:52 -04:00
Matt Bierner
0610f195fb Try automatically adding .md file extension to new paths on rename 2022-04-21 22:23:51 -04:00
Matt Bierner
0ac39e800d Add support for renaming files in markdown using F2
This lets you trigger F2 on a file path in a markdown link to both rename the file and also update all references to it
2022-04-21 22:23:51 -04:00
Matt Bierner
9fbd962973 Differentiate md refs request on file path vs on fragment 2022-04-21 22:23:50 -04:00
Matt Bierner
08e838cba3 Don't encode paths 2022-04-19 10:13:38 -07:00
Matt Bierner
cba0a0e460 Always encode paths dropped in md 2022-04-14 14:55:22 -07:00
Akat
b499467f9f fix(markdown): avoid considering link references/sources in code sections (#146826) 2022-04-07 14:50:37 -07:00
Matt Bierner
bba6c56123 Fix dropping image from webpage into markdown files 2022-04-06 14:27:41 -07:00
Matt Bierner
27759c6e03 Use limiter instead of custom batcher 2022-04-06 14:16:06 -07:00
Matt Bierner
62d6f38fc2 Auto create image links when dropping an image file into markdown 2022-04-05 15:42:56 -07:00
Matt Bierner
032ee47056 Add setting to enable/disable markdown drop into editor
For #142990
2022-04-05 15:42:56 -07:00
Matt Bierner
b4b7380576 Fix md references not checking authority
Simply compare by string for now
2022-04-05 15:31:43 -07:00
Matt Bierner
a56c9f10b7 Enable find all references and rename of auto links and http(s) links in markdown
For #146777, #146277
2022-04-05 15:18:18 -07:00