diff --git a/extensions/markdown-language-features/package.json b/extensions/markdown-language-features/package.json index 6cf7ccef60c34..fbcc7885befb2 100644 --- a/extensions/markdown-language-features/package.json +++ b/extensions/markdown-language-features/package.json @@ -544,19 +544,26 @@ ], "default": "never", "markdownDescription": "%configuration.markdown.updateLinksOnFileMove.enabled%", - "scope": "resource" + "scope": "window" }, - "markdown.updateLinksOnFileMove.externalFileGlobs": { - "type": "string", - "default": "**/*.{jpg,jpe,jpeg,png,bmp,gif,ico,webp,avif,tiff,svg,mp4}", - "description": "%configuration.markdown.updateLinksOnFileMove.fileGlobs%", - "scope": "resource" + "markdown.updateLinksOnFileMove.include": { + "type": "array", + "markdownDescription": "%configuration.markdown.updateLinksOnFileMove.include%", + "scope": "window", + "items": { + "type": "string", + "description": "%configuration.markdown.updateLinksOnFileMove.include.property%" + }, + "default": [ + "**/*.{md,mkd,mdwn,mdown,markdown,markdn,mdtxt,mdtext,workbook}", + "**/*.{jpg,jpe,jpeg,png,bmp,gif,ico,webp,avif,tiff,svg,mp4}" + ] }, "markdown.updateLinksOnFileMove.enableForDirectories": { "type": "boolean", "default": true, "description": "%configuration.markdown.updateLinksOnFileMove.enableForDirectories%", - "scope": "resource" + "scope": "window" }, "markdown.occurrencesHighlight.enabled": { "type": "boolean", diff --git a/extensions/markdown-language-features/package.nls.json b/extensions/markdown-language-features/package.nls.json index 98a100b1bd56d..92bada665624b 100644 --- a/extensions/markdown-language-features/package.nls.json +++ b/extensions/markdown-language-features/package.nls.json @@ -41,11 +41,12 @@ "configuration.markdown.validate.ignoredLinks.description": "Configure links that should not be validated. For example adding `/about` would not validate the link `[about](/about)`, while the glob `/assets/**/*.svg` would let you skip validation for any link to `.svg` files under the `assets` directory.", "configuration.markdown.validate.unusedLinkDefinitions.description": "Validate link definitions that are unused in the current file.", "configuration.markdown.validate.duplicateLinkDefinitions.description": "Validate duplicated definitions in the current file.", - "configuration.markdown.updateLinksOnFileMove.enabled": "Try to update links in Markdown files when a file is renamed/moved in the workspace. Use `#markdown.updateLinksOnFileMove.externalFileGlobs#` to configure which files trigger link updates.", + "configuration.markdown.updateLinksOnFileMove.enabled": "Try to update links in Markdown files when a file is renamed/moved in the workspace. Use `#markdown.updateLinksOnFileMove.include#` to configure which files trigger link updates.", "configuration.markdown.updateLinksOnFileMove.enabled.prompt": "Prompt on each file move.", "configuration.markdown.updateLinksOnFileMove.enabled.always": "Always update links automatically.", "configuration.markdown.updateLinksOnFileMove.enabled.never": "Never try to update link and don't prompt.", - "configuration.markdown.updateLinksOnFileMove.fileGlobs": "A glob that specifies which files besides markdown should trigger a link update.", + "configuration.markdown.updateLinksOnFileMove.include": "Glob patterns that specifies which files that trigger automatic link updates. See `#markdown.updateLinksOnFileMove.enabled#` for details about this feature.", + "configuration.markdown.updateLinksOnFileMove.include.property": "The glob pattern to match file paths against. Set to true or false to enable or disable the pattern.", "configuration.markdown.updateLinksOnFileMove.enableForDirectories": "Enable/disable updating links when a directory is moved or renamed in the workspace.", "configuration.markdown.occurrencesHighlight.enabled": "Enable/disable highlighting link occurrences in the current document.", "workspaceTrust": "Required for loading styles configured in the workspace." diff --git a/extensions/markdown-language-features/src/languageFeatures/linkUpdater.ts b/extensions/markdown-language-features/src/languageFeatures/linkUpdater.ts index 98d7e7271125f..39d083f13297a 100644 --- a/extensions/markdown-language-features/src/languageFeatures/linkUpdater.ts +++ b/extensions/markdown-language-features/src/languageFeatures/linkUpdater.ts @@ -12,14 +12,13 @@ import { MdLanguageClient } from '../client/client'; import { Delayer } from '../util/async'; import { noopToken } from '../util/cancellation'; import { Disposable } from '../util/dispose'; -import { looksLikeMarkdownPath } from '../util/file'; import { convertRange } from './fileReferences'; const localize = nls.loadMessageBundle(); const settingNames = Object.freeze({ enabled: 'updateLinksOnFileMove.enabled', - externalFileGlobs: 'updateLinksOnFileMove.externalFileGlobs', + include: 'updateLinksOnFileMove.include', enableForDirectories: 'updateLinksOnFileMove.enableForDirectories', }); @@ -99,13 +98,13 @@ class UpdateLinksOnFileRenameHandler extends Disposable { return false; } - if (looksLikeMarkdownPath(newUri)) { - return true; - } - - const externalGlob = config.get(settingNames.externalFileGlobs); - if (!!externalGlob && picomatch.isMatch(newUri.fsPath, externalGlob)) { - return true; + const externalGlob = config.get(settingNames.include); + if (externalGlob) { + for (const glob of externalGlob) { + if (picomatch.isMatch(newUri.fsPath, glob)) { + return true; + } + } } const stat = await vscode.workspace.fs.stat(newUri);