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
markdown link smart pasting #188437
markdown link smart pasting #188437
Conversation
Co-authored-by: Joyce Er <joyceerhl@gmail.com>
extensions/markdown-language-features/src/languageFeatures/copyFiles/copyPasteLinks.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Show resolved
Hide resolved
extensions/markdown-language-features/src/test/markdownLink.test.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/test/markdownLink.test.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/copyPasteLinks.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/copyPasteLinks.ts
Outdated
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Show resolved
Hide resolved
extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts
Show resolved
Hide resolved
test('link to link snippet', async () => { | ||
// createEditAddingLinksForUriList -> checkSmartPaste -> tryGetUriListSnippet -> createUriListSnippet -> createLinkSnippet | ||
|
||
const skinnyDocument: SkinnyTextDocument = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you add more tests, you may be able to use something like https://github.com/microsoft/vscode-markdown-languageservice/blob/1d9f6887521b3e3ce906595ef39a3e35d6d0e85c/src/test/inMemoryDocument.ts#L11 for this. Notice how it uses the TextDocument
type from vscode-languageserver-textdocument
which implements much of the API for you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to get this merged in for testing during endgame
Please follow up on the remaining comments during debt week
const uri = vscode.Uri.parse('https://www.microsoft.com'); | ||
const snippet = createLinkSnippet(false, 'https://www.microsoft.com', '', uri, 0, true); | ||
const uri = vscode.Uri.parse('https://www.microsoft.com/'); | ||
const snippet = appendToLinkSnippet(new vscode.SnippetString(''), false, 'https:/www.microsoft.com', '', uri, 0, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appendToLinkSnippet(new vscode.Snippet('')
still looks weird to me. Why did it have to get changed vs createLinkSnippet
? Is there a way you can avoid this?
const smartPaste = checkSmartPaste('$$$\r\n\r\n$$$', 5, 5); | ||
assert.strictEqual(smartPaste.pasteAsMarkdownLink, false); | ||
}); | ||
const inlineMathSkinnyDoc: SkinnyTextDocument = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try moving constants used inside the test into the test itself. This makes them easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also want to create a helper function that creates SkinnyTextDocuments
Or even better, add a new class that implements SkinnyTextDocuments
for your tests. That way you can just call new InMemoryDocument('doc text')
or something similar
When pasting a link into the Markdown editor, the link should automatically be converted to a Markdown link. This feature should be smart enough to enable this automatically only when it makes sense.