Skip to content

Commit

Permalink
Fix frontmatter line map
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Apr 4, 2024
1 parent 641eb4c commit d15f4fd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
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

0 comments on commit d15f4fd

Please sign in to comment.