Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frontmatter line map #209556

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix frontmatter line map
Fixes #209267
  • Loading branch information
mjbvz committed Apr 4, 2024
commit d15f4fddaa1a68659230fc731246000b67e9f015
2 changes: 1 addition & 1 deletion extensions/markdown-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
"dompurify": "^3.0.5",
"highlight.js": "^11.8.0",
"markdown-it": "^12.3.2",
"markdown-it-front-matter": "^0.2.1",
"markdown-it-front-matter": "^0.2.4",
"morphdom": "^2.6.1",
"picomatch": "^2.3.1",
"vscode-languageclient": "^8.0.2",
Expand Down
32 changes: 32 additions & 0 deletions extensions/markdown-language-features/src/test/pasteUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { InsertMarkdownLink, findValidUriInText, shouldInsertMarkdownLinkByDefau
import { noopToken } from '../util/cancellation';
import { UriList } from '../util/uriList';
import { createNewMarkdownEngine } from './engine';
import { joinLines } from './util';

function makeTestDoc(contents: string) {
return new InMemoryDocument(vscode.Uri.file('test.md'), contents);
Expand Down Expand Up @@ -307,5 +308,36 @@ suite('createEditAddingLinksForUriList', () => {
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), makeTestDoc('<>'), InsertMarkdownLink.Smart, [new vscode.Range(0, 1, 0, 1)], noopToken),
false);
});

test('Smart should be disabled in frontmatter', async () => {
const textDoc = makeTestDoc(joinLines(
`---`,
`layout: post`,
`title: Blogging Like a Hacker`,
`---`,
``,
`Link Text`
));
assert.strictEqual(
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), textDoc, InsertMarkdownLink.Smart, [new vscode.Range(0, 0, 0, 0)], noopToken),
false);

assert.strictEqual(
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), textDoc, InsertMarkdownLink.Smart, [new vscode.Range(1, 0, 1, 0)], noopToken),
false);
});

test('Smart should enabled after frontmatter', async () => {
assert.strictEqual(
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), makeTestDoc(joinLines(
`---`,
`layout: post`,
`title: Blogging Like a Hacker`,
`---`,
``,
`Link Text`
)), InsertMarkdownLink.Smart, [new vscode.Range(5, 0, 5, 0)], noopToken),
true);
});
});
});
8 changes: 4 additions & 4 deletions extensions/markdown-language-features/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

markdown-it-front-matter@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/markdown-it-front-matter/-/markdown-it-front-matter-0.2.1.tgz#dca49a827bb3cebb0528452c1d87dff276eb28dc"
integrity sha512-ydUIqlKfDscRpRUTRcA3maeeUKn3Cl5EaKZSA+I/f0KOGCBurW7e+bbz59sxqkC3FA9Q2S2+t4mpkH9T0BCM6A==
markdown-it-front-matter@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/markdown-it-front-matter/-/markdown-it-front-matter-0.2.4.tgz#cf29bc8222149b53575699357b1ece697bf39507"
integrity sha512-25GUs0yjS2hLl8zAemVndeEzThB1p42yxuDEKbd4JlL3jiz+jsm6e56Ya8B0VREOkNxLYB4TTwaoPJ3ElMmW+w==

markdown-it@^12.3.2:
version "12.3.2"
Expand Down
Loading