|
13 | 13 | See the License for the specific language governing permissions and |
14 | 14 | limitations under the License. |
15 | 15 | */ |
16 | | -import { commands } from "vscode"; |
| 16 | +import { commands, window } from "vscode"; |
17 | 17 | import { LOGGER } from "../logger"; |
18 | 18 | import { NbProcessManager } from "./nbProcessManager"; |
19 | 19 | import { clientInit } from "./initializer"; |
20 | 20 | import { NbLanguageClient } from "./nbLanguageClient"; |
21 | 21 | import { globalState } from "../globalState"; |
| 22 | +import { l10n } from "../localiser"; |
22 | 23 |
|
23 | 24 | export class ClientPromise { |
24 | 25 | setClient!: [(c: NbLanguageClient) => void, (err: any) => void]; |
@@ -60,24 +61,32 @@ export class ClientPromise { |
60 | 61 | } |
61 | 62 |
|
62 | 63 | public restartExtension = async (nbProcessManager: NbProcessManager | null, notifyKill: boolean) => { |
63 | | - if (this.activationPending) { |
64 | | - LOGGER.warn("Server activation requested repeatedly, ignoring..."); |
65 | | - return; |
66 | | - } |
67 | | - if (!nbProcessManager) { |
| 64 | + if (nbProcessManager) { |
| 65 | + try { |
| 66 | + globalState.setDeactivated(true); |
| 67 | + await this.stopClient(); |
| 68 | + await nbProcessManager.killProcess(notifyKill); |
| 69 | + this.initialize(); |
| 70 | + clientInit(); |
| 71 | + } catch (error) { |
| 72 | + LOGGER.error(`Error during activation: ${error}`); |
| 73 | + const reloadNow: string = l10n.value("jdk.downloader.message.reload"); |
| 74 | + const dialogBoxMessage = l10n.value("jdk.configChangedFailed"); |
| 75 | + const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow); |
| 76 | + if (selected === reloadNow) { |
| 77 | + await commands.executeCommand('workbench.action.reloadWindow'); |
| 78 | + } |
| 79 | + } finally { |
| 80 | + this.activationPending = false; |
| 81 | + } |
| 82 | + }else{ |
68 | 83 | LOGGER.error("Nbcode Process is null"); |
69 | | - return; |
70 | | - } |
71 | | - try { |
72 | | - await this.stopClient(); |
73 | | - await nbProcessManager.killProcess(notifyKill); |
74 | | - this.initialize(); |
75 | | - clientInit(); |
76 | | - } catch (error) { |
77 | | - LOGGER.error(`Error during activation: ${error}`); |
78 | | - throw error; |
79 | | - } finally { |
80 | | - this.activationPending = false; |
| 84 | + const reloadNow: string = l10n.value("jdk.downloader.message.reload"); |
| 85 | + const dialogBoxMessage = l10n.value("jdk.configChanged"); |
| 86 | + const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow); |
| 87 | + if (selected === reloadNow) { |
| 88 | + await commands.executeCommand('workbench.action.reloadWindow'); |
| 89 | + } |
81 | 90 | } |
82 | 91 | } |
83 | 92 |
|
|
0 commit comments