1
const q = vscode.window.createQuickPick();
q.items = [{ label: "1" }, { label: "2" }];
q.activeItems = [{ label: "2" }];
q.show();

Based on my understand of vscode extension api doc.

/**
  * Active items. This can be read and updated by the extension.
  */
activeItems: readonly T[];

it should active "2" item when quickpick is showing. But I found activeItems will reset after show() method; I dont know why and cant find any same issue in the internet,

BarrySong
  • 11
  • 1

1 Answers1

0

it seems that a bug is impacting behavior here

my solution was to set the active items after calling the show method. Also it seems the code does reference comparisons.

So

const q = vscode.window.createQuickPick();
const selectedItem = { label: "2" };
q.items = [{ label: "1" }, selectedItem];
q.show();
q.activeItems = [selectedItem];
baywet
  • 4,377
  • 4
  • 20
  • 49