Skip to content

Commit

Permalink
fix: double listed command
Browse files Browse the repository at this point in the history
fix: first entry in flag list not expanding
  • Loading branch information
Daniel OBrien committed Feb 1, 2024
1 parent f7ca4ae commit 45041bf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "launchdarkly",
"displayName": "LaunchDarkly",
"description": "Manage LaunchDarkly feature flags directly from within your code",
"version": "4.99.50",
"version": "4.99.51",
"publisher": "launchdarklyofficial",
"engines": {
"vscode": "^1.82.0"
Expand Down
48 changes: 27 additions & 21 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ export async function setupComponents(config: LDExtensionConfiguration, reload =
if (enableFlagListView) {
const listView = new LaunchDarklyFlagListProvider(config, codeLens);
window.registerTreeDataProvider('launchdarklyFlagList', listView);
listViewDisp = commands.registerCommand('launchdarkly.refreshFlagLens', () => listView.setFlagsinDocument());
config.getCtx().subscriptions.push(window.onDidChangeActiveTextEditor(listView.setFlagsinDocument), listViewDisp);
if (!reload) {
listViewDisp = commands.registerCommand('launchdarkly.refreshFlagLens', () => listView.setFlagsinDocument());
config.getCtx().subscriptions.push(listViewDisp);
}

config.getCtx().subscriptions.push(window.onDidChangeActiveTextEditor(listView.setFlagsinDocument));
}

const enableReleasesView = workspace.getConfiguration('launchdarkly').get('enableReleasesView', false);
Expand All @@ -98,12 +102,6 @@ export async function setupComponents(config: LDExtensionConfiguration, reload =
const hoverProviderDisp = languages.registerHoverProvider(LD_MODE, new LaunchDarklyHoverProvider(config));

try {
const flagToggle = commands.registerCommand('launchdarkly.toggleFlagCmdPrompt', async () => {
await showToggleMenu(config);
});
const openFlag = commands.registerCommand('launchdarkly.OpenFlag', (node: FlagItem) =>
window.activeTextEditor.revealRange(node.range),
);
const codeLensProv = languages.registerCodeLensProvider([LD_MODE], codeLens);

config
Expand All @@ -117,23 +115,31 @@ export async function setupComponents(config: LDExtensionConfiguration, reload =
'"',
),
hoverProviderDisp,
flagToggle,
openFlag,
);

codeLens.start();

const disposables = await generalCommands(config);

const allDisposables = Disposable.from(
disposables,
hoverProviderDisp,
listViewDisp,
flagToggle,
openFlag,
codeLensProv,
);
await config.getCtx().globalState.update('commands', allDisposables);
if (!reload) {
const flagToggle = commands.registerCommand('launchdarkly.toggleFlagCmdPrompt', async () => {
await showToggleMenu(config);
});
const openFlag = commands.registerCommand('launchdarkly.OpenFlag', (node: FlagItem) =>
window.activeTextEditor.revealRange(node.range),
);

const disposables = await generalCommands(config);

const allDisposables = Disposable.from(
disposables,
hoverProviderDisp,
listViewDisp,
flagToggle,
openFlag,
codeLensProv,
);
await config.getCtx().globalState.update('commands', allDisposables);
config.getCtx().subscriptions.push(flagToggle, openFlag);
}
} catch (err) {
console.error(err);
}
Expand Down

0 comments on commit 45041bf

Please sign in to comment.