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

markdown link smart pasting #188437

Merged

Conversation

MeghanKulkarni
Copy link
Contributor

@MeghanKulkarni MeghanKulkarni commented Jul 21, 2023

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.

test('link to link snippet', async () => {
// createEditAddingLinksForUriList -> checkSmartPaste -> tryGetUriListSnippet -> createUriListSnippet -> createLinkSnippet

const skinnyDocument: SkinnyTextDocument = {
Copy link
Contributor

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

@MeghanKulkarni MeghanKulkarni marked this pull request as ready for review July 24, 2023 22:49
@VSCodeTriageBot VSCodeTriageBot added this to the July 2023 milestone Jul 24, 2023
Copy link
Contributor

@mjbvz mjbvz left a 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);
Copy link
Contributor

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 = {
Copy link
Contributor

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

Copy link
Contributor

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

@MeghanKulkarni MeghanKulkarni merged commit 87afa16 into microsoft:main Jul 24, 2023
6 checks passed
@MeghanKulkarni MeghanKulkarni deleted the MeghanKulkarni/smart-paste branch July 26, 2023 21:34
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants