Skip to content

🔨 Fix markdown diagnostics issue with files having dot in their names#153206

Closed
babakks wants to merge 5 commits into
microsoft:mainfrom
babakks:fix-checking-md-files-without-extension
Closed

🔨 Fix markdown diagnostics issue with files having dot in their names#153206
babakks wants to merge 5 commits into
microsoft:mainfrom
babakks:fix-checking-md-files-without-extension

Conversation

@babakks

@babakks babakks commented Jun 25, 2022

Copy link
Copy Markdown
Contributor

This PR fixes #153094

@mjbvz Do you think this simply works? Or there are further complications?

@babakks babakks marked this pull request as ready for review June 25, 2022 14:33
return originalUri;
}

// We don't think the file exists. If it doesn't already have an extension, try tacking on a `.md` and using that instead

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in an extra file system access when resolving links so not really a fan. Any other ideas on fixing this in a more pragmatic way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. As a more pragmatic approach, I revived the if statement with a little change to check for the file existence only if the given extension was something other than .md. This just resolves the current issue (i.e., where there is a period within the file name) and spares the check for most of the cases, I believe, where there's the .md extension present.

@babakks babakks force-pushed the fix-checking-md-files-without-extension branch 2 times, most recently from 922872e to 690f4cb Compare June 28, 2022 12:20
@babakks babakks force-pushed the fix-checking-md-files-without-extension branch from 690f4cb to fd6012d Compare June 28, 2022 12:27
// We don't think the file exists. If it doesn't already have an extension, try tacking on a `.md` and using that instead
if (uri.Utils.extname(originalUri) === '') {
// We don't think the file exists. If it doesn't already have a `.md` extension, try tacking on a `.md` and using that instead
if (uri.Utils.extname(originalUri) !== '.md') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems ok. You can use the looksLikeMarkdownPath helper for this to handle other md file extensions too:

export function looksLikeMarkdownPath(resolvedHrefPath: vscode.Uri) {

Maybe we should also skip this check for common image file extensions (.jpg, .png, .gif, ...)

@babakks babakks Jun 28, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hint. I've now added a new helper function, named looksLikeImagePath, to exclude image files too.

@mjbvz mjbvz added this to the July 2022 milestone Jun 29, 2022
@mjbvz

mjbvz commented Jun 29, 2022

Copy link
Copy Markdown
Collaborator

Thanks! Will merge for the July release since our current release (1.69) is in testing/polishing mode

@mjbvz mjbvz added the on-release-notes Issue/pull request mentioned in release notes label Jul 21, 2022
@mjbvz

mjbvz commented Jul 21, 2022

Copy link
Copy Markdown
Collaborator

Ah sorry this dropped off my radar

The code for markdown diagnostics code has been moved to this project: https://github.com/microsoft/vscode-markdown-languageservice/

I'm going to close this PR and port over it to that repo

@mjbvz mjbvz closed this Jul 21, 2022
mjbvz added a commit to microsoft/vscode-markdown-languageservice that referenced this pull request Jul 21, 2022
@babakks babakks deleted the fix-checking-md-files-without-extension branch July 22, 2022 11:12
@babakks

babakks commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

@mjbvz Thank you.

@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

on-release-notes Issue/pull request mentioned in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Experimental markdown validate doesn't work for local links without file extension specified if file name contains period . characters

2 participants