Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #44237: Add columnNumber variable #213252

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/vs/server/node/remoteTerminalChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class CustomVariableResolver extends AbstractVariableResolverService {
getLineNumber: (): string | undefined => {
return resolvedVariables['lineNumber'];
},
getColumnNumber: (): string | undefined => {
return resolvedVariables['columnNumber'];
},
getExtension: async id => {
const installed = await extensionService.getInstalled();
const found = installed.find(e => e.identifier.id === id);
Expand Down
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 @@ -115,6 +115,17 @@ export abstract class BaseConfigurationResolverService extends AbstractVariableR
}
return undefined;
},
getColumnNumber: (): string | undefined => {
const activeTextEditorControl = editorService.activeTextEditorControl;
if (isCodeEditor(activeTextEditorControl)) {
const selection = activeTextEditorControl.getSelection();
if (selection) {
const colNumber = selection.positionColumn;
return String(colNumber);
}
}
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