Skip to content

Commit 5296b0f

Browse files
authored
Add explicit "inherit" setting for fragments links (microsoft#162231)
Fixes microsoft#162129
1 parent 06f29ea commit 5296b0f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

extensions/markdown-language-features/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,9 @@
477477
"type": "string",
478478
"scope": "resource",
479479
"markdownDescription": "%configuration.markdown.validate.fileLinks.markdownFragmentLinks.description%",
480-
"default": "ignore",
480+
"default": "inherit",
481481
"enum": [
482+
"inherit",
482483
"ignore",
483484
"warning",
484485
"error"

extensions/markdown-language-features/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The server supports the following settings:
6464
- `enabled` — Enable/disable validation of links to fragments in the current files: `[text](#head)`
6565
- `fileLinks`
6666
- `enabled` — Enable/disable validation of links to file in the workspace.
67-
- `markdownFragmentLinks` — Enable/disable validation of links to headers in other Markdown files.
67+
- `markdownFragmentLinks` — Enable/disable validation of links to headers in other Markdown files. Use `inherit` to inherit the `fragmentLinks` setting.
6868
- `ignoredLinks` — Array of glob patterns for files that should not be validated.
6969

7070
### Custom requests

extensions/markdown-language-features/server/src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Settings {
2626
};
2727
readonly fileLinks: {
2828
readonly enabled: ValidateEnabled;
29-
readonly markdownFragmentLinks: ValidateEnabled;
29+
readonly markdownFragmentLinks: ValidateEnabled | 'inherit';
3030
};
3131
readonly ignoredLinks: readonly string[];
3232
};

extensions/markdown-language-features/server/src/languageFeatures/diagnostics.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ function getDiagnosticsOptions(config: ConfigurationManager): md.DiagnosticOptio
3333
return defaultDiagnosticOptions;
3434
}
3535

36+
const validateFragmentLinks = convertDiagnosticLevel(settings.markdown.validate.fragmentLinks.enabled);
3637
return {
3738
validateFileLinks: convertDiagnosticLevel(settings.markdown.validate.fileLinks.enabled),
3839
validateReferences: convertDiagnosticLevel(settings.markdown.validate.referenceLinks.enabled),
39-
validateFragmentLinks: convertDiagnosticLevel(settings.markdown.validate.fragmentLinks.enabled),
40-
validateMarkdownFileLinkFragments: convertDiagnosticLevel(settings.markdown.validate.fileLinks.markdownFragmentLinks),
40+
validateFragmentLinks,
41+
validateMarkdownFileLinkFragments: settings.markdown.validate.fileLinks.markdownFragmentLinks === 'inherit' ? validateFragmentLinks : convertDiagnosticLevel(settings.markdown.validate.fileLinks.markdownFragmentLinks),
4142
ignoreLinks: settings.markdown.validate.ignoredLinks,
4243
};
4344
}

0 commit comments

Comments
 (0)