parent
5220135992
commit
b9f33fc242
|
@ -335,7 +335,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
|
|||
}
|
||||
|
||||
private toTsTriggerReason(context: vscode.CodeActionContext): Proto.RefactorTriggerReason | undefined {
|
||||
if (context.triggerKind === vscode.CodeActionTriggerKind.Manual) {
|
||||
if (context.triggerKind === vscode.CodeActionTriggerKind.Invoke) {
|
||||
return 'invoked';
|
||||
}
|
||||
return undefined;
|
||||
|
@ -389,7 +389,7 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider<TsCodeActi
|
|||
return false;
|
||||
}
|
||||
|
||||
return context.triggerKind === vscode.CodeActionTriggerKind.Manual;
|
||||
return context.triggerKind === vscode.CodeActionTriggerKind.Invoke;
|
||||
}
|
||||
|
||||
private static getKind(refactor: Proto.RefactorActionInfo) {
|
||||
|
|
|
@ -699,8 +699,8 @@ export interface CodeAction {
|
|||
* @internal
|
||||
*/
|
||||
export const enum CodeActionTriggerType {
|
||||
Auto = 1,
|
||||
Manual = 2,
|
||||
Invoke = 1,
|
||||
Auto = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -247,7 +247,7 @@ CommandsRegistry.registerCommand('_executeCodeActionProvider', async function (a
|
|||
const codeActionSet = await getCodeActions(
|
||||
model,
|
||||
validatedRangeOrSelection,
|
||||
{ type: modes.CodeActionTriggerType.Manual, filter: { includeSourceActions: true, include } },
|
||||
{ type: modes.CodeActionTriggerType.Invoke, filter: { includeSourceActions: true, include } },
|
||||
Progress.None,
|
||||
CancellationToken.None);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ export class QuickFixController extends Disposable implements IEditorContributio
|
|||
|
||||
MessageController.get(this._editor).closeMessage();
|
||||
const triggerPosition = this._editor.getPosition();
|
||||
this._trigger({ type: CodeActionTriggerType.Manual, filter, autoApply, context: { notAvailableMessage, position: triggerPosition } });
|
||||
this._trigger({ type: CodeActionTriggerType.Invoke, filter, autoApply, context: { notAvailableMessage, position: triggerPosition } });
|
||||
}
|
||||
|
||||
private _trigger(trigger: CodeActionTrigger) {
|
||||
|
|
|
@ -247,7 +247,7 @@ export class CodeActionModel extends Disposable {
|
|||
}
|
||||
|
||||
const actions = createCancelablePromise(token => getCodeActions(model, trigger.selection, trigger.trigger, Progress.None, token));
|
||||
if (trigger.trigger.type === CodeActionTriggerType.Manual) {
|
||||
if (trigger.trigger.type === CodeActionTriggerType.Invoke) {
|
||||
this._progressService?.showWhile(actions, 250);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ export class CodeActionUi extends Disposable {
|
|||
|
||||
this._lightBulbWidget.getValue().update(actions, newState.trigger, newState.position);
|
||||
|
||||
if (newState.trigger.type === CodeActionTriggerType.Manual) {
|
||||
if (newState.trigger.type === CodeActionTriggerType.Invoke) {
|
||||
if (newState.trigger.filter?.include) { // Triggered for specific scope
|
||||
// Check to see if we want to auto apply.
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ suite('CodeAction', () => {
|
|||
new CodeActionItem(testData.tsLint.abc, provider)
|
||||
];
|
||||
|
||||
const { validActions: actions } = await getCodeActions(model, new Range(1, 1, 2, 1), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, new Range(1, 1, 2, 1), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.equal(actions.length, 6);
|
||||
assert.deepEqual(actions, expected);
|
||||
});
|
||||
|
|
|
@ -46,7 +46,7 @@ export class MarkerHover implements IHoverPart {
|
|||
}
|
||||
|
||||
const markerCodeActionTrigger: CodeActionTrigger = {
|
||||
type: CodeActionTriggerType.Manual,
|
||||
type: CodeActionTriggerType.Invoke,
|
||||
filter: { include: CodeActionKind.QuickFix }
|
||||
};
|
||||
|
||||
|
|
12
src/vs/vscode.proposed.d.ts
vendored
12
src/vs/vscode.proposed.d.ts
vendored
|
@ -2672,18 +2672,18 @@ declare module 'vscode' {
|
|||
* The reason why code actions were requested.
|
||||
*/
|
||||
export enum CodeActionTriggerKind {
|
||||
/**
|
||||
* Code actions were explicitly requested by the user or by an extension.
|
||||
*/
|
||||
Invoke = 1,
|
||||
|
||||
/**
|
||||
* Code actions were requested automatically.
|
||||
*
|
||||
* This typically happens when current selection in a file changes, but can
|
||||
* also be triggered when file content changes.
|
||||
*/
|
||||
Automatic = 1,
|
||||
|
||||
/**
|
||||
* Code actions were requested maually by the user or an extension.
|
||||
*/
|
||||
Manual = 2,
|
||||
Automatic = 2,
|
||||
}
|
||||
|
||||
export interface CodeActionContext {
|
||||
|
|
|
@ -1731,11 +1731,11 @@ export namespace CodeActionTriggerKind {
|
|||
|
||||
export function to(value: modes.CodeActionTriggerType): types.CodeActionTriggerKind {
|
||||
switch (value) {
|
||||
case modes.CodeActionTriggerType.Invoke:
|
||||
return types.CodeActionTriggerKind.Invoke;
|
||||
|
||||
case modes.CodeActionTriggerType.Auto:
|
||||
return types.CodeActionTriggerKind.Automatic;
|
||||
|
||||
case modes.CodeActionTriggerType.Manual:
|
||||
return types.CodeActionTriggerKind.Manual;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1179,8 +1179,8 @@ export class DocumentSymbol {
|
|||
|
||||
|
||||
export enum CodeActionTriggerKind {
|
||||
Automatic = 1,
|
||||
Manual = 2,
|
||||
Invoke = 1,
|
||||
Automatic = 2,
|
||||
}
|
||||
|
||||
@es5ClassCompat
|
||||
|
|
|
@ -695,7 +695,7 @@ export class MarkerViewModel extends Disposable {
|
|||
if (!this.codeActionsPromise) {
|
||||
this.codeActionsPromise = createCancelablePromise(cancellationToken => {
|
||||
return getCodeActions(model, new Range(this.marker.range.startLineNumber, this.marker.range.startColumn, this.marker.range.endLineNumber, this.marker.range.endColumn), {
|
||||
type: CodeActionTriggerType.Manual, filter: { include: CodeActionKind.QuickFix }
|
||||
type: CodeActionTriggerType.Invoke, filter: { include: CodeActionKind.QuickFix }
|
||||
}, Progress.None, cancellationToken).then(actions => {
|
||||
return this._register(actions);
|
||||
});
|
||||
|
|
|
@ -591,7 +591,7 @@ suite('ExtHostLanguageFeatures', function () {
|
|||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 2);
|
||||
const [first, second] = actions;
|
||||
assert.strictEqual(first.action.title, 'Testing1');
|
||||
|
@ -615,7 +615,7 @@ suite('ExtHostLanguageFeatures', function () {
|
|||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
const [first] = actions;
|
||||
assert.strictEqual(first.action.title, 'Testing1');
|
||||
|
@ -638,7 +638,7 @@ suite('ExtHostLanguageFeatures', function () {
|
|||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
});
|
||||
|
||||
|
@ -656,7 +656,7 @@ suite('ExtHostLanguageFeatures', function () {
|
|||
}));
|
||||
|
||||
await rpcProtocol.sync();
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Manual }, Progress.None, CancellationToken.None);
|
||||
const { validActions: actions } = await getCodeActions(model, model.getFullModelRange(), { type: modes.CodeActionTriggerType.Invoke }, Progress.None, CancellationToken.None);
|
||||
assert.strictEqual(actions.length, 1);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue