add new variable ${relativeFileDirname}; fixes #77616
This commit is contained in:
parent
caad996fba
commit
eeaffa91a3
2 changed files with 21 additions and 5 deletions
|
@ -63,11 +63,20 @@ function registerVariableCompletions(pattern: string): vscode.Disposable {
|
||||||
const indexOf$ = document.lineAt(position.line).text.indexOf('$');
|
const indexOf$ = document.lineAt(position.line).text.indexOf('$');
|
||||||
const startPosition = indexOf$ >= 0 ? new vscode.Position(position.line, indexOf$) : position;
|
const startPosition = indexOf$ >= 0 ? new vscode.Position(position.line, indexOf$) : position;
|
||||||
|
|
||||||
return [{ label: 'workspaceFolder', detail: localize('workspaceFolder', "The path of the folder opened in VS Code") }, { label: 'workspaceFolderBasename', detail: localize('workspaceFolderBasename', "The name of the folder opened in VS Code without any slashes (/)") },
|
return [
|
||||||
{ label: 'relativeFile', detail: localize('relativeFile', "The current opened file relative to ${workspaceFolder}") }, { label: 'file', detail: localize('file', "The current opened file") }, { label: 'cwd', detail: localize('cwd', "The task runner's current working directory on startup") },
|
{ label: 'workspaceFolder', detail: localize('workspaceFolder', "The path of the folder opened in VS Code") },
|
||||||
{ label: 'lineNumber', detail: localize('lineNumber', "The current selected line number in the active file") }, { label: 'selectedText', detail: localize('selectedText', "The current selected text in the active file") },
|
{ label: 'workspaceFolderBasename', detail: localize('workspaceFolderBasename', "The name of the folder opened in VS Code without any slashes (/)") },
|
||||||
{ label: 'fileDirname', detail: localize('fileDirname', "The current opened file's dirname") }, { label: 'fileExtname', detail: localize('fileExtname', "The current opened file's extension") }, { label: 'fileBasename', detail: localize('fileBasename', "The current opened file's basename") },
|
{ label: 'relativeFile', detail: localize('relativeFile', "The current opened file relative to ${workspaceFolder}") },
|
||||||
{ label: 'fileBasenameNoExtension', detail: localize('fileBasenameNoExtension', "The current opened file's basename with no file extension") }].map(variable => ({
|
{ label: 'relativeFileDirname', detail: localize('relativeFileDirname', "The current opened file's dirname relative to ${workspaceFolder}") },
|
||||||
|
{ label: 'file', detail: localize('file', "The current opened file") },
|
||||||
|
{ label: 'cwd', detail: localize('cwd', "The task runner's current working directory on startup") },
|
||||||
|
{ label: 'lineNumber', detail: localize('lineNumber', "The current selected line number in the active file") },
|
||||||
|
{ label: 'selectedText', detail: localize('selectedText', "The current selected text in the active file") },
|
||||||
|
{ label: 'fileDirname', detail: localize('fileDirname', "The current opened file's dirname") },
|
||||||
|
{ label: 'fileExtname', detail: localize('fileExtname', "The current opened file's extension") },
|
||||||
|
{ label: 'fileBasename', detail: localize('fileBasename', "The current opened file's basename") },
|
||||||
|
{ label: 'fileBasenameNoExtension', detail: localize('fileBasenameNoExtension', "The current opened file's basename with no file extension") }
|
||||||
|
].map(variable => ({
|
||||||
label: '${' + variable.label + '}',
|
label: '${' + variable.label + '}',
|
||||||
range: new vscode.Range(startPosition, position),
|
range: new vscode.Range(startPosition, position),
|
||||||
detail: variable.detail
|
detail: variable.detail
|
||||||
|
|
|
@ -237,6 +237,13 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
|
||||||
}
|
}
|
||||||
return getFilePath();
|
return getFilePath();
|
||||||
|
|
||||||
|
case 'relativeFileDirname':
|
||||||
|
let dirname = paths.dirname(getFilePath());
|
||||||
|
if (folderUri) {
|
||||||
|
return paths.normalize(paths.relative(getFolderUri().fsPath, dirname));
|
||||||
|
}
|
||||||
|
return dirname;
|
||||||
|
|
||||||
case 'fileDirname':
|
case 'fileDirname':
|
||||||
return paths.dirname(getFilePath());
|
return paths.dirname(getFilePath());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue