Rework markdown update link glob (#164766)

* Rework markdown update link glob

Fixes #164587

This changes the `externalFileGlobs` setting to instead be a include array of globs that should trigger link updates. I've split the globs into markdown files and image/video files

This also makes it easier for users to add their own new globs to the list

* Fix scopes
This commit is contained in:
Matt Bierner
2022-10-26 16:45:45 -07:00
committed by GitHub
parent d2f8ae6cce
commit 1316bf789f
3 changed files with 25 additions and 18 deletions

View File

@@ -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<string>(settingNames.externalFileGlobs);
if (!!externalGlob && picomatch.isMatch(newUri.fsPath, externalGlob)) {
return true;
const externalGlob = config.get<string[]>(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);