(
server: LspServerDefinition,
options: { promptConfirm?: boolean } = {},
)
| 810 | } |
| 811 | |
| 812 | export async function uninstallServer( |
| 813 | server: LspServerDefinition, |
| 814 | options: { promptConfirm?: boolean } = {}, |
| 815 | ): Promise<boolean> { |
| 816 | const bundle = getServerBundle(server.id); |
| 817 | if (bundle?.uninstallServer) { |
| 818 | return bundle.uninstallServer(server.id, server, options); |
| 819 | } |
| 820 | |
| 821 | const { promptConfirm = false } = options; |
| 822 | const cacheKey = getInstallCacheKey(server); |
| 823 | const displayLabel = getInstallLabel(server); |
| 824 | const command = getUninstallCommand(server); |
| 825 | |
| 826 | if (!command) { |
| 827 | throw new Error(`${displayLabel} has no uninstall command.`); |
| 828 | } |
| 829 | |
| 830 | if (promptConfirm) { |
| 831 | notificationManager.pushNotification({ |
| 832 | icon: "zap", |
| 833 | title: displayLabel, |
| 834 | message: strings["lsp-uninstall-notification"].replace( |
| 835 | "{server}", |
| 836 | displayLabel, |
| 837 | ), |
| 838 | type: "warning", |
| 839 | action: (notification) => { |
| 840 | uninstallServer(server, { promptConfirm: false }); |
| 841 | notificationManager.closeNotification(notification); |
| 842 | }, |
| 843 | }); |
| 844 | return false; |
| 845 | } |
| 846 | |
| 847 | let loading = true; |
| 848 | try { |
| 849 | notificationManager.pushNotification({ |
| 850 | icon: "zap", |
| 851 | title: displayLabel, |
| 852 | message: `Uninstalling ${displayLabel}...`, |
| 853 | loading: () => loading, |
| 854 | }); |
| 855 | //await runForegroundCommand(command); |
| 856 | await runQuickCommand(command); |
| 857 | if (cacheKey) { |
| 858 | checkedCommands.delete(cacheKey); |
| 859 | } |
| 860 | resetInstallState(server.id); |
| 861 | stopManagedServer(server.id); |
| 862 | return true; |
| 863 | } catch (error) { |
| 864 | console.error(`Failed to uninstall ${server.id}`, error); |
| 865 | toast(strings?.error ?? "Error"); |
| 866 | throw error; |
| 867 | } finally { |
| 868 | loading = false; |
| 869 | } |
no test coverage detected