Skip to content

Commit 3774c72

Browse files
committed
WIP
Signed-off-by: Rob Stryker <rob@oxbeef.net>
1 parent 775a96f commit 3774c72

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎src/extension.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
321321
}
322322
const result = [];
323323
for (const item of values) {
324-
console.log(`[reveal-debug] provideCodeActions item: ${JSON.stringify(item).substring(0, 300)}`);
325324
if (Command.is(item)) {
326325
result.push(client.protocol2CodeConverter.asCommand(item));
327326
}
@@ -1382,17 +1381,18 @@ export function escapeSnippetLiterals(value: string): string {
13821381
* VS Code applies the edit of a code action itself and doesn't show the edited file.
13831382
* Attach a command, which VS Code runs after applying the edit, to reveal the change
13841383
* when it is made in a document other than the active one.
1384+
* Any command the action already has is passed along and run first.
13851385
*/
13861386
function addRevealCommand(codeAction: CodeAction): CodeAction {
13871387
console.log(`[reveal-debug] addRevealCommand: "${codeAction.title}" edit=${!!codeAction.edit} command=${codeAction.command?.command}`);
1388-
if (codeAction.edit && !codeAction.command) {
1388+
if (codeAction.edit && codeAction.command?.command !== Commands.REVEAL_EDIT) {
13891389
for (const [uri, edits] of codeAction.edit.entries()) {
13901390
if (edits.length > 0) {
13911391
console.log(`[reveal-debug] attaching reveal to "${codeAction.title}" -> ${uri.toString()}`);
13921392
codeAction.command = {
13931393
title: 'Reveal edit',
13941394
command: Commands.REVEAL_EDIT,
1395-
arguments: [uri, edits[0].range],
1395+
arguments: [uri, edits[0].range, codeAction.command],
13961396
};
13971397
break;
13981398
}

‎src/standardLanguageClient.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as net from 'net';
44
import * as path from 'path';
5-
import { CancellationToken, CodeActionKind, commands, ConfigurationTarget, DocumentSelector, EventEmitter, ExtensionContext, extensions, languages, Location, ProgressLocation, Range, TextEditor, TextEditorRevealType, Uri, ViewColumn, window, workspace, WorkspaceConfiguration } from "vscode";
5+
import { CancellationToken, CodeActionKind, Command, commands, ConfigurationTarget, DocumentSelector, EventEmitter, ExtensionContext, extensions, languages, Location, ProgressLocation, Range, TextEditor, TextEditorRevealType, Uri, ViewColumn, window, workspace, WorkspaceConfiguration } from "vscode";
66
import { ConfigurationParams, ConfigurationRequest, LanguageClientOptions, Location as LSLocation, MessageType, Position as LSPosition, TextDocumentPositionParams, WorkspaceEdit, StaticFeature, ClientCapabilities, FeatureState, TelemetryEventNotification } from "vscode-languageclient";
77
import { LanguageClient, StreamInfo } from "vscode-languageclient/node";
88
import { apiManager } from "./apiManager";
@@ -444,8 +444,11 @@ export class StandardLanguageClient {
444444
await revealWorkspaceEdit(obj, this.languageClient, activeUri);
445445
}));
446446

447-
context.subscriptions.push(commands.registerCommand(Commands.REVEAL_EDIT, async (uri: Uri, range: Range) => {
447+
context.subscriptions.push(commands.registerCommand(Commands.REVEAL_EDIT, async (uri: Uri, range: Range, originalCommand?: Command) => {
448448
console.log(`[reveal-debug] ${Commands.REVEAL_EDIT}: ${uri.toString()}, active: ${window.activeTextEditor?.document.uri.toString()}`);
449+
if (originalCommand) {
450+
await commands.executeCommand(originalCommand.command, ...(originalCommand.arguments ?? []));
451+
}
449452
if (window.activeTextEditor?.document.uri.toString() === uri.toString()) {
450453
return;
451454
}

0 commit comments

Comments
 (0)