@ttsc/vscode 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/extension.js CHANGED
@@ -14963,11 +14963,11 @@ var require_client = __commonJS({
14963
14963
  ErrorAction2[ErrorAction2["Continue"] = 1] = "Continue";
14964
14964
  ErrorAction2[ErrorAction2["Shutdown"] = 2] = "Shutdown";
14965
14965
  })(ErrorAction || (exports2.ErrorAction = ErrorAction = {}));
14966
- var CloseAction;
14967
- (function(CloseAction2) {
14968
- CloseAction2[CloseAction2["DoNotRestart"] = 1] = "DoNotRestart";
14969
- CloseAction2[CloseAction2["Restart"] = 2] = "Restart";
14970
- })(CloseAction || (exports2.CloseAction = CloseAction = {}));
14966
+ var CloseAction2;
14967
+ (function(CloseAction3) {
14968
+ CloseAction3[CloseAction3["DoNotRestart"] = 1] = "DoNotRestart";
14969
+ CloseAction3[CloseAction3["Restart"] = 2] = "Restart";
14970
+ })(CloseAction2 || (exports2.CloseAction = CloseAction2 = {}));
14971
14971
  var State;
14972
14972
  (function(State2) {
14973
14973
  State2[State2["Stopped"] = 1] = "Stopped";
@@ -15007,14 +15007,14 @@ var require_client = __commonJS({
15007
15007
  closed() {
15008
15008
  this.restarts.push(Date.now());
15009
15009
  if (this.restarts.length <= this.maxRestartCount) {
15010
- return { action: CloseAction.Restart };
15010
+ return { action: CloseAction2.Restart };
15011
15011
  } else {
15012
15012
  let diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
15013
15013
  if (diff <= 3 * 60 * 1e3) {
15014
- return { action: CloseAction.DoNotRestart, message: `The ${this.client.name} server crashed ${this.maxRestartCount + 1} times in the last 3 minutes. The server will not be restarted. See the output for more information.` };
15014
+ return { action: CloseAction2.DoNotRestart, message: `The ${this.client.name} server crashed ${this.maxRestartCount + 1} times in the last 3 minutes. The server will not be restarted. See the output for more information.` };
15015
15015
  } else {
15016
15016
  this.restarts.shift();
15017
- return { action: CloseAction.Restart };
15017
+ return { action: CloseAction2.Restart };
15018
15018
  }
15019
15019
  }
15020
15020
  }
@@ -15927,7 +15927,7 @@ var require_client = __commonJS({
15927
15927
  }
15928
15928
  } catch (error) {
15929
15929
  }
15930
- let handlerResult = { action: CloseAction.DoNotRestart };
15930
+ let handlerResult = { action: CloseAction2.DoNotRestart };
15931
15931
  if (this.$state !== ClientState.Stopping) {
15932
15932
  try {
15933
15933
  handlerResult = await this._clientOptions.errorHandler.closed();
@@ -15935,7 +15935,7 @@ var require_client = __commonJS({
15935
15935
  }
15936
15936
  }
15937
15937
  this._connection = void 0;
15938
- if (handlerResult.action === CloseAction.DoNotRestart) {
15938
+ if (handlerResult.action === CloseAction2.DoNotRestart) {
15939
15939
  this.error(handlerResult.message ?? "Connection to server got closed. Server will not be restarted.", void 0, handlerResult.handled === true ? false : "force");
15940
15940
  this.cleanUp("stop");
15941
15941
  if (this.$state === ClientState.Starting) {
@@ -15945,7 +15945,7 @@ var require_client = __commonJS({
15945
15945
  }
15946
15946
  this._onStop = Promise.resolve();
15947
15947
  this._onStart = void 0;
15948
- } else if (handlerResult.action === CloseAction.Restart) {
15948
+ } else if (handlerResult.action === CloseAction2.Restart) {
15949
15949
  this.info(handlerResult.message ?? "Connection to server got closed. Server will restart.", !handlerResult.handled);
15950
15950
  this.cleanUp("restart");
15951
15951
  this.$state = ClientState.Initial;
@@ -18191,6 +18191,26 @@ function isOrderedRange(start, end) {
18191
18191
  return start.line < end.line || start.line === end.line && start.character <= end.character;
18192
18192
  }
18193
18193
 
18194
+ // src/expectedServerRestart.ts
18195
+ function createExpectedServerRestartHandler(fallback, restart) {
18196
+ let expected = false;
18197
+ return {
18198
+ errorHandler: {
18199
+ error: (...args) => fallback.error(...args),
18200
+ closed: () => {
18201
+ if (!expected) {
18202
+ return fallback.closed();
18203
+ }
18204
+ expected = false;
18205
+ return restart;
18206
+ }
18207
+ },
18208
+ expectRestart: () => {
18209
+ expected = true;
18210
+ }
18211
+ };
18212
+ }
18213
+
18194
18214
  // src/serverResolution.ts
18195
18215
  var import_node_crypto = require("node:crypto");
18196
18216
  var import_node_fs = __toESM(require("node:fs"));
@@ -18471,6 +18491,25 @@ function serverProcessOptions(cwd) {
18471
18491
  }
18472
18492
 
18473
18493
  // src/extension.ts
18494
+ var METHOD_PLUGIN_SELECTION_CHANGED = "ttsc/pluginSelectionChanged";
18495
+ var expectedRestartHandlers = /* @__PURE__ */ new WeakMap();
18496
+ var TtscLanguageClient = class extends import_node.LanguageClient {
18497
+ createDefaultErrorHandler(maxRestartCount) {
18498
+ const controller = createExpectedServerRestartHandler(
18499
+ super.createDefaultErrorHandler(maxRestartCount),
18500
+ {
18501
+ action: import_node.CloseAction.Restart,
18502
+ handled: true,
18503
+ message: "ttsc plugin selection changed; restarting language server."
18504
+ }
18505
+ );
18506
+ expectedRestartHandlers.set(this, controller);
18507
+ return controller.errorHandler;
18508
+ }
18509
+ expectPluginSelectionRestart() {
18510
+ expectedRestartHandlers.get(this)?.expectRestart();
18511
+ }
18512
+ };
18474
18513
  var clients = /* @__PURE__ */ new Map();
18475
18514
  var reconcileQueue = Promise.resolve();
18476
18515
  var sharedTraceChannel;
@@ -18810,12 +18849,15 @@ function isSupportedDocument(document) {
18810
18849
  );
18811
18850
  }
18812
18851
  async function startClient(spec, traceChannel) {
18813
- const client = new import_node.LanguageClient(
18852
+ const client = new TtscLanguageClient(
18814
18853
  "ttsc",
18815
18854
  spec.name,
18816
18855
  spec.serverOptions,
18817
18856
  buildClientOptions(traceChannel, spec)
18818
18857
  );
18858
+ client.onNotification(METHOD_PLUGIN_SELECTION_CHANGED, () => {
18859
+ client.expectPluginSelectionRestart();
18860
+ });
18819
18861
  const ready = client.start().catch((error) => {
18820
18862
  if (clients.get(spec.id)?.client === client) {
18821
18863
  clients.delete(spec.id);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ttsc/vscode",
3
3
  "displayName": "ttsc",
4
4
  "description": "TypeScript-Go and ttsc plugin diagnostics, completions, lint actions, and formatting for VS Code.",
5
- "version": "0.21.0",
5
+ "version": "0.22.0",
6
6
  "publisher": "samchon",
7
7
  "icon": "images/icon.png",
8
8
  "license": "MIT",
@@ -81,7 +81,7 @@
81
81
  "ttsc.serverPath": {
82
82
  "type": "string",
83
83
  "default": "",
84
- "description": "Absolute path to a ttscserver launcher, native binary, or Windows .cmd/.bat command shim. Leave empty to use the project ttsc launcher, which builds TTSC_LSP_PLUGINS_JSON for plugin diagnostics/actions; direct native paths need that manifest supplied out of band.",
84
+ "description": "Absolute path to a ttscserver launcher, native binary, or Windows .cmd/.bat command shim. Leave empty to use the project ttsc launcher, which passes the resolved plugin manifest through --lsp-plugins-file for plugin diagnostics/actions; direct native paths need that manifest supplied out of band via TTSC_LSP_PLUGINS_FILE.",
85
85
  "scope": "resource"
86
86
  },
87
87
  "ttsc.trace.server": {
@@ -105,7 +105,7 @@
105
105
  "rimraf": "^6.1.2",
106
106
  "typescript": "^7.0.2",
107
107
  "vscode-languageclient": "^9.0.1",
108
- "ttsc": "0.21.0"
108
+ "ttsc": "0.22.0"
109
109
  },
110
110
  "scripts": {
111
111
  "build": "rimraf lib dist && node build/build.cjs"