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

vscode.executeCodeActionProvider result not eqal to WorkspaceEdit.renameFile #224064

Open
AlexCannonball opened this issue Jul 27, 2024 · 0 comments
Assignees

Comments

@AlexCannonball
Copy link

AlexCannonball commented Jul 27, 2024

Type: Bug

Hello,

I've made unit/integration tests for vscode extension via @vscode/test-electron.

When I compare an actual renameFile code action obtained via

async function getCodeActions(
  uri: Uri,
  expectedRange: Range,
): Promise<CodeAction[]> {
  return commands.executeCommand<CodeAction[]>(
    'vscode.executeCodeActionProvider',
    uri,
    expectedRange,
  );
}

and the expected code action created via

const renameFileAction: TExpectedActions = function (uri, { parsedMessage }) {
  const fixedUri = Uri.joinPath(uri, '..', parsedMessage[FIX_KEY]);

  const action = new CodeAction('', CodeActionKind.QuickFix);

  action.isPreferred = true;
  action.edit = new WorkspaceEdit();

  action.edit.renameFile(uri, fixedUri, {
    overwrite: false,
  });

  return [action];
};

I see that there is difference in edit.c[0].to._formatted property. The value in actual object is not null, unlike the expected value (red color for the actual value):

image

The extension code building this code action is similar to the snippet for expected object in tests:

    const action = new CodeAction(
      `Rename the file to '${parsedMessage[FIX_KEY]}'`,
      CodeActionKind.QuickFix,
    );

    action.isPreferred = true;
    action.edit = new WorkspaceEdit();

    const fixedUri: Uri = Uri.joinPath(uri, '..', parsedMessage[FIX_KEY]);

    action.edit.renameFile(uri, fixedUri, { overwrite: false });

The issue is reproduced when I run tests normally and isn't reproduced when I debug the extension tests with breakpoints.

VS Code version: Code 1.91.1 (f1e16e1, 2024-07-09T22:06:49.809Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 5700U with Radeon Graphics (16 x 1797)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 14.82GB (6.24GB free)
Process Argv --log info --log plex.vscode-protolint=trace --crash-reporter-id 1760485e-64d5-4472-924c-6ff6ba32397c
Screen Reader no
VM 0%
Extensions (10)
Extension Author (truncated) Version
vscode-eslint dba 3.0.10
gitlens eam 15.2.2
EditorConfig Edi 0.16.4
prettier-vscode esb 10.4.0
remote-wsl ms- 0.88.2
vscode-twoslash-queries Ort 1.2.2
vscode-yaml red 1.15.0
code-spell-checker str 3.0.1
pretty-ts-errors Yoa 0.5.4
vscode-proto3 zxh 0.5.5

(1 theme extensions excluded)

A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
f3je6385:31013174
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
newcmakeconfigv2:31071590
impr_priority:31102340
refactorc:31101458
pythonrstrctxtcf:31093870
wkspc-onlycs-t:31100202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants