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

enhance(common): don't reload workspace when running doctor airtable command #2620

Merged
merged 3 commits into from Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/engine-server/src/doctor/service.ts
Expand Up @@ -389,7 +389,7 @@ export class DoctorService implements Disposable {
custom: { ...note.custom, pods },
};
// update note
engine.writeNote(updatedNote, { updateExisting: true });
await engine.writeNote(updatedNote, { updateExisting: true });
};
break;
}
Expand Down
28 changes: 26 additions & 2 deletions packages/plugin-core/src/commands/Doctor.ts
Expand Up @@ -91,6 +91,30 @@ export enum PluginDoctorActionsEnum {
FIX_KEYBINDING_CONFLICTS = "fixKeybindingConflicts",
}

// Only reload the workspace for these commands
// ^2z4m76v2e2xo
const RELOAD_BEFORE_ACTIONS: (PluginDoctorActionsEnum | DoctorActionsEnum)[] = [
DoctorActionsEnum.FIX_FRONTMATTER,
DoctorActionsEnum.CREATE_MISSING_LINKED_NOTES,
];

const RELOAD_AFTER_ACTIONS: (PluginDoctorActionsEnum | DoctorActionsEnum)[] = [
DoctorActionsEnum.FIX_FRONTMATTER,
DoctorActionsEnum.CREATE_MISSING_LINKED_NOTES,
];

function shouldDoctorReloadWorkspaceBeforeDoctorAction(
action: PluginDoctorActionsEnum | DoctorActionsEnum
) {
return RELOAD_BEFORE_ACTIONS.includes(action);
}

function shouldDoctorReloadWorkspaceAfterDoctorAction(
action: PluginDoctorActionsEnum | DoctorActionsEnum
) {
return RELOAD_AFTER_ACTIONS.includes(action);
}

export class DoctorCommand extends BasicCommand<CommandOpts, CommandOutput> {
key = DENDRON_COMMANDS.DOCTOR.key;
private extension: IDendronExtension;
Expand Down Expand Up @@ -342,7 +366,7 @@ export class DoctorCommand extends BasicCommand<CommandOpts, CommandOutput> {
}
this.L.info({ ctx, msg: "pre:Reload" });

if (opts.action !== PluginDoctorActionsEnum.FIND_INCOMPATIBLE_EXTENSIONS) {
if (shouldDoctorReloadWorkspaceBeforeDoctorAction(opts.action)) {
await this.reload();
}

Expand Down Expand Up @@ -496,7 +520,7 @@ export class DoctorCommand extends BasicCommand<CommandOpts, CommandOutput> {
this.extension.fileWatcher.pause = false;
}

if (opts.action !== PluginDoctorActionsEnum.FIND_INCOMPATIBLE_EXTENSIONS) {
if (shouldDoctorReloadWorkspaceAfterDoctorAction(opts.action)) {
await this.reload();
// Decorations don't auto-update here, I think because the contents of the
// note haven't updated within VSCode yet. Regenerate the decorations, but
Expand Down