fix a bug where toggling the next edit settings sometimes won't do anything

This commit is contained in:
Jacob Kim 2025-06-25 10:52:44 -07:00
parent 79c0ccb96e
commit 3183982525
2 changed files with 36 additions and 26 deletions

View file

@ -141,31 +141,33 @@ export class NextEditWindowManager {
false,
);
const existingCommands = await vscode.commands.getCommands();
// Helper function to register commands safely.
const registerCommandSafely = (
commandId: string,
callback: () => Promise<void>,
) => {
try {
const command = vscode.commands.registerCommand(commandId, callback);
context.subscriptions.push(command);
} catch (error) {
console.log(
`Command ${commandId} already has an associated callback, skipping registration`,
);
}
};
if (!existingCommands.includes(HIDE_TOOLTIP_COMMAND)) {
// Register the command to hide tooltips
const hideTooltipsCommand = vscode.commands.registerCommand(
HIDE_TOOLTIP_COMMAND,
async () => {
await this.hideAllTooltips();
},
);
context.subscriptions.push(hideTooltipsCommand);
}
// Register HIDE_TOOLTIP_COMMAND and ACCEPT_NEXT_EDIT_COMMAND
// with their corresponding callbacks.
registerCommandSafely(
HIDE_TOOLTIP_COMMAND,
async () => await this.hideAllTooltips(),
);
registerCommandSafely(
ACCEPT_NEXT_EDIT_COMMAND,
async () => await this.acceptNextEdit(),
);
if (!existingCommands.includes(ACCEPT_NEXT_EDIT_COMMAND)) {
// Register the command to accept next edit
const acceptNextEditCommand = vscode.commands.registerCommand(
ACCEPT_NEXT_EDIT_COMMAND,
() => {
this.acceptNextEdit();
},
);
context.subscriptions.push(acceptNextEditCommand);
}
// Add this class to context disposables
// Add this class to context disposables.
context.subscriptions.push(this);
if (textApplier) {
@ -222,6 +224,13 @@ export class NextEditWindowManager {
"nextEditWindowActive",
true,
);
console.log(
await vscode.commands.executeCommand(
"getContext",
"nextEditWindowActive",
),
);
}
/**

View file

@ -18,8 +18,9 @@ export function ContinueFeaturesMenu({
const { session } = useAuth();
useEffect(() => {
// Only run this effect when both optInNextEditFeature is true and session is available.
// This still sets up the next edit window manager when the user leaves the setting on
// before exiting vscode.
// This effectively handles cases where there user
// leaves the setting on before exiting vscode,
// which leaves the toggle to be on.
if (optInNextEditFeature && session) {
const continueEmail = (session as HubSessionInfo)?.account?.id ?? null;
if (continueEmail) {
@ -35,7 +36,7 @@ export function ContinueFeaturesMenu({
handleUpdate({
optInNextEditFeature: value,
});
// Send message to VSCode extension with the email
// Send message to VSCode extension with the email.
const continueEmail = (session as HubSessionInfo)?.account?.id ?? null;
if (continueEmail) {
ideMessenger.post("optInNextEditFeature", {