Skip to content

Commit

Permalink
Fixes #44237: Add columnNumber variable
Browse files Browse the repository at this point in the history
This adds a new variable that you can access from tasks and other
places to be able to substitute in the currently selected column number
from the active editor.
  • Loading branch information
keithel-qt committed May 22, 2024
1 parent 4ebc77f commit 3148b1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vs/workbench/api/common/extHostVariableResolverService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ class ExtHostVariableResolverService extends AbstractVariableResolverService {
}
return undefined;
},
getColumnNumber: (): string | undefined => {
if (editorService) {
const activeEditor = editorService.activeEditor();
if (activeEditor) {
return String(activeEditor.selection.end.character + 1);
}
}
return undefined;
},
getExtension: (id) => {
return extensionService.getExtension(id);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface IVariableResolveContext {
getWorkspaceFolderPathForFile?(): string | undefined;
getSelectedText(): string | undefined;
getLineNumber(): string | undefined;
getColumnNumber(): string | undefined;
getExtension(id: string): Promise<{ readonly extensionLocation: uri } | undefined>;
}

Expand Down Expand Up @@ -307,6 +308,13 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
}
throw new VariableError(VariableKind.LineNumber, localize('canNotResolveLineNumber', "Variable {0} can not be resolved. Make sure to have a line selected in the active editor.", match));
}
case 'columnNumber': {
const colNumber = this._context.getColumnNumber();
if (colNumber) {
return colNumber;
}
throw new VariableError(VariableKind.LineNumber, localize('canNotResolveColumnNumber', "Variable {0} can not be resolved. Make sure to have a column selected in the active editor.", match));
}
case 'selectedText': {
const selectedText = this._context.getSelectedText();
if (selectedText) {
Expand Down

0 comments on commit 3148b1a

Please sign in to comment.