Commit Graph

54 Commits

Author SHA1 Message Date
Matt Bierner
bd5b480c23 Use areUrisEqual helper for better uri checks 2026-03-27 00:42:39 -07:00
Matt Bierner
243bce7593 Merge branch 'main' into fix/janky-scrolling-in-markdown-preview 2026-03-26 15:14:38 -07:00
Matt Bierner
7df46143a1 Experiment with switching markdown extension to use native privates
Let's try this out with one extension to start
2026-03-10 23:13:16 -07:00
Matt Bierner
909a106725 Use case insentive file uri compare in md extension
For #265277
2026-03-10 19:27:33 -07:00
AshtonYoon
8cfe3492f9 markdown: fix janky scrolling in preview with code blocks
Fixes #278930

This commit fixes the scroll synchronization issues between the markdown
editor and preview when scrolling through code blocks:

1. **Code block line tracking**: Added endLine calculation for fenced
   code blocks by counting newlines, enabling accurate line-to-position
   mapping within multi-line code blocks.

2. **Padding-aware scrolling**: Implemented getContentBounds() to
   calculate scroll positions excluding padding, preventing jumps when
   scrolling through code blocks with padding.

3. **Scroll loop prevention**: Changed scroll disable flags from counters
   to timer-based booleans (50ms) to prevent infinite sync loops while
   maintaining smooth bidirectional synchronization.

The fix ensures smooth scrolling through code blocks without jumping or
stuttering in both directions (editor ↔ preview).
2026-01-12 12:39:02 +09:00
Matt Bierner
b38fb3f7f1 Don't watch non-writable fs for md preview updates
Fixes #277389
2025-11-14 10:32:54 -08:00
Matt Bierner
c47a56c7bc Adopt uuids for generating webview nonces 2025-10-29 13:53:47 -07:00
Matt Bierner
73e6d6a0a2 Enable a few more stylistic eslint options for my extensions 2025-08-14 10:42:20 -07:00
Matt Bierner
73f244c82b Make sure to escape cspSource
Good practice

Also makes sure we don't include full file uris in the csp
2025-05-22 00:01:01 -07:00
Matt Bierner
aa986f0d99 Include preview roots in list of allowed markdown preview csp roots
Fixes #249321
2025-05-19 16:47:17 -07:00
notoriousmango
c4f757d3ce verbose to trace 2025-02-20 18:42:41 +09:00
Matt Bierner
d70e0e2fe0 Merge pull request #236406 from mjbvz/confidential-trout
Small cleanup follow up on #236145
2024-12-17 12:22:16 -08:00
Matt Bierner
a47b13ebc2 Small cleanup follow up on #236145
- Don't send content as json
- Reuse existing load helper
2024-12-17 11:59:05 -08:00
Matt Bierner
4559089128 Merge pull request #234649 from notoriousmango/feat-open-image
Add 'open image' context in markdown preview
2024-12-17 11:55:25 -08:00
Parasaran
ca72122751 fix 235221: Encode and decode markdown content to escape illegal chars 2024-12-17 23:32:42 +05:30
Parasaran
da1d8b9c8e fix 235221: Passing the markdown content to the webview via meta tag and purifying it before use 2024-12-17 22:57:12 +05:30
notoriousmango
f7c3b1b474 use openDocumentLink 2024-12-15 00:11:54 +09:00
notoriousmango
0715a50f63 move openImage logic to command 2024-11-27 17:03:33 +09:00
notoriousmango
0b243279cc open image 2024-11-26 19:53:31 +09:00
Matt Bierner
d81d32b940 Re-render markdown preview when linkify setting changes (#200599) 2024-01-11 17:23:13 -08:00
Matt Bierner
19f9f605a9 Correctly reload markdown preview on md contribution change (#188218)
Fixes #184295
2023-07-19 01:47:31 +02:00
Matt Bierner
6aca75d9d0 Fix markdown preview classes (#187501)
For #187234

Got introduced through a bad PR change. Makes more sense to move this styling to the css file instead
2023-07-10 13:04:03 -07:00
Hans
48ff3ffb7c Fix #182013 (#184677)
* Fix #182013

* 💄

* 💄
2023-06-21 17:10:09 +00:00
MeghanKulkarni
67cc0965b3 allow images in markdown preview editor to be copied (#184432)
* allow images in markdown preview editor to be copied

* resolved feedback

* added findPreview method

* removed copy image command from showPreview

* clean up

---------

Co-authored-by: Meghan Kulkarni <t-mekulkarni@microsoft.com>
2023-06-07 18:08:22 +00:00
Matt Bierner
87a6bda310 Fix opening encoded markdown fragment in preview (#178465)
Fixes #178340
2023-03-28 08:59:30 +02:00
Matt Bierner
7800bd3492 Clamp line to > 0 (#176970)
Fixes #176924
2023-03-13 16:37:19 +01:00
Matt Bierner
3ca5284e44 Clean up markdown preview messaging (#176458)
- Add properties directly to message
- Add `ImageInfo` type
- Don't use state to pass around imageInfo
2023-03-07 17:28:13 -08:00
Matt Bierner
6a44101bb1 Type markdown preview webview message (#176444)
Simply types messages. Will clean up types in next pass
2023-03-07 14:23:17 -08:00
Ely Ronnen
59f6d52062 fix #174711 Show Source command in Markdown custom editor (#174712)
fix #174711
2023-02-20 16:01:36 +00:00
Matt Bierner
ac88f33e2c Revert "Fix: New md file scrolls to Top. (#164999)" (#168224)
This reverts commit 54543cf5bf.
2022-12-06 22:50:30 +01:00
Debayan Ganguly
54543cf5bf Fix: New md file scrolls to Top. (#164999)
Fixes #164071.
2022-11-09 13:48:39 -08:00
Matt Bierner
cd29f751eb Adopt l10n for markdown extension (#165448)
For #164438

Also makes our eslint rules understand `vscode.l10n.t(`
2022-11-04 09:49:49 +01:00
Matt Bierner
33867c55f3 Adopt prefix private with _ in markdown extension (#165088) 2022-10-31 14:22:39 -07:00
Matt Bierner
504c5a768a Avoid extra html write on first markdown preview update (#164201) 2022-10-20 19:40:19 -07:00
Matt Bierner
bfb1a738d1 Fix markdown open preview opening duplicate preview (#162793)
This fixes the markdown 'open preview' command when used with `vscode.ViewColumn.Active` or `vscode.ViewColumn.Beside`
2022-10-06 09:50:10 +02:00
Matt Bierner
b8a7485526 Fix markdown preview refresh from disk (#161800)
Fixes #149974
2022-09-26 09:49:53 -07:00
Matt Bierner
f4bf1f30a2 Skip ul and ol when highlighting selected markdown element (#161139)
Fixes #155552

For lists, the outer ul/ol always has the same source line as the first element in the list. We should prefer using the first element in the list when highlighting the active line

This also fixes a bug where scroll sync would stop working if you added lines to the doc. This was caused by `lineCount` getting out of sync as the document is being updated. I've removed this state and made the reveal logic more robust instead
2022-09-19 07:16:06 +02:00
Matt Bierner
2d27f8db6a Use MD LS for resolving all document links (#160238)
* Use MD LS for resolving all document links

This switches the markdown extension to use the markdown language service when resolving the link. This lets us delete a lot of code that was duplicated between the extension and the LS

* Pick up new ls version
2022-09-07 20:55:14 -07:00
Matt Bierner
389938998f Show error when markdown preview restore fails (#157566)
Fixes #155493
2022-08-09 09:55:40 +02:00
Matt Bierner
b012216211 Fix markdown images having duplicate ids (#157177)
Fixes #153144
2022-08-05 06:31:42 +02:00
Matt Bierner
784de60319 Add activeWebviewPanelId context key (#156944)
Fixes #156942

This context tracks the id of the active webviewPanel
2022-08-03 07:03:33 +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
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
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
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
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
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
590a9bf8a3 Make sure double click in md preview always reveals target line
Fixes #146333
2022-03-30 15:49:56 -07:00
Matt Bierner
4949f13d13 Organize imports 2022-03-29 13:25:40 -07:00