Skip to content

Commit 7a623b3

Browse files
authored
Fix frontmatter line map (microsoft#209556)
Fixes microsoft#209267
1 parent 125e308 commit 7a623b3

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

extensions/markdown-language-features/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@
771771
"dompurify": "^3.0.5",
772772
"highlight.js": "^11.8.0",
773773
"markdown-it": "^12.3.2",
774-
"markdown-it-front-matter": "^0.2.1",
774+
"markdown-it-front-matter": "^0.2.4",
775775
"morphdom": "^2.6.1",
776776
"picomatch": "^2.3.1",
777777
"vscode-languageclient": "^8.0.2",

extensions/markdown-language-features/src/test/pasteUrl.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { InsertMarkdownLink, findValidUriInText, shouldInsertMarkdownLinkByDefau
1111
import { noopToken } from '../util/cancellation';
1212
import { UriList } from '../util/uriList';
1313
import { createNewMarkdownEngine } from './engine';
14+
import { joinLines } from './util';
1415

1516
function makeTestDoc(contents: string) {
1617
return new InMemoryDocument(vscode.Uri.file('test.md'), contents);
@@ -307,5 +308,36 @@ suite('createEditAddingLinksForUriList', () => {
307308
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), makeTestDoc('<>'), InsertMarkdownLink.Smart, [new vscode.Range(0, 1, 0, 1)], noopToken),
308309
false);
309310
});
311+
312+
test('Smart should be disabled in frontmatter', async () => {
313+
const textDoc = makeTestDoc(joinLines(
314+
`---`,
315+
`layout: post`,
316+
`title: Blogging Like a Hacker`,
317+
`---`,
318+
``,
319+
`Link Text`
320+
));
321+
assert.strictEqual(
322+
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), textDoc, InsertMarkdownLink.Smart, [new vscode.Range(0, 0, 0, 0)], noopToken),
323+
false);
324+
325+
assert.strictEqual(
326+
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), textDoc, InsertMarkdownLink.Smart, [new vscode.Range(1, 0, 1, 0)], noopToken),
327+
false);
328+
});
329+
330+
test('Smart should enabled after frontmatter', async () => {
331+
assert.strictEqual(
332+
await shouldInsertMarkdownLinkByDefault(createNewMarkdownEngine(), makeTestDoc(joinLines(
333+
`---`,
334+
`layout: post`,
335+
`title: Blogging Like a Hacker`,
336+
`---`,
337+
``,
338+
`Link Text`
339+
)), InsertMarkdownLink.Smart, [new vscode.Range(5, 0, 5, 0)], noopToken),
340+
true);
341+
});
310342
});
311343
});

extensions/markdown-language-features/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ lru-cache@^6.0.0:
242242
dependencies:
243243
yallist "^4.0.0"
244244

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

250250
markdown-it@^12.3.2:
251251
version "12.3.2"

0 commit comments

Comments
 (0)