typescript-language-server 5.0.1 → 5.1.1

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/cli.mjs CHANGED
@@ -1,21 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import fs$2, { promises, statSync, existsSync, readFileSync } from 'node:fs';
3
3
 
4
- import require$$0 from 'node:events';
5
-
6
- import require$$1 from 'node:child_process';
7
-
8
- import * as path from 'node:path';
9
-
10
- import path__default, { extname, resolve } from 'node:path';
11
-
12
- import process$1 from 'node:process';
13
-
14
- import require$$0$4, { promisify as promisify$1 } from 'node:util';
4
+ import { createRequire } from 'node:module';
15
5
 
16
- import require$$0$1, { promisify } from 'util';
6
+ import require$$0, { promisify } from 'util';
17
7
 
18
- import require$$1$1 from 'path';
8
+ import require$$1 from 'path';
19
9
 
20
10
  import require$$2 from 'os';
21
11
 
@@ -23,15 +13,19 @@ import crypto from 'crypto';
23
13
 
24
14
  import require$$4 from 'net';
25
15
 
26
- import require$$0$2 from 'url';
16
+ import require$$0$1 from 'url';
27
17
 
28
- import require$$0$3 from 'fs';
18
+ import require$$0$2 from 'fs';
29
19
 
30
20
  import require$$3 from 'child_process';
31
21
 
32
- import require$$0$5 from 'constants';
22
+ import * as path from 'node:path';
23
+
24
+ import path__default, { extname, resolve } from 'node:path';
33
25
 
34
- import require$$0$6 from 'stream';
26
+ import require$$0$3 from 'constants';
27
+
28
+ import require$$0$4 from 'stream';
35
29
 
36
30
  import require$$5 from 'assert';
37
31
 
@@ -41,9 +35,13 @@ import 'node:fs/promises';
41
35
 
42
36
  import stream from 'node:stream';
43
37
 
44
- import { createRequire } from 'node:module';
38
+ import { promisify as promisify$1 } from 'node:util';
39
+
40
+ import ChildProcess from 'node:child_process';
45
41
 
46
- import require$$1$2 from 'fs/promises';
42
+ import require$$1$1 from 'fs/promises';
43
+
44
+ import process$1 from 'node:process';
47
45
 
48
46
  import { fileURLToPath } from 'node:url';
49
47
 
@@ -173,6 +171,36 @@ function requireArgument() {
173
171
 
174
172
  var command = {};
175
173
 
174
+ const require$5 = createRequire(import.meta.url);
175
+
176
+ function __require$5() {
177
+ return require$5('node:events');
178
+ }
179
+
180
+ const require$4 = createRequire(import.meta.url);
181
+
182
+ function __require$4() {
183
+ return require$4('node:child_process');
184
+ }
185
+
186
+ const require$3 = createRequire(import.meta.url);
187
+
188
+ function __require$3() {
189
+ return require$3('node:path');
190
+ }
191
+
192
+ const require$2 = createRequire(import.meta.url);
193
+
194
+ function __require$2() {
195
+ return require$2('node:fs');
196
+ }
197
+
198
+ const require$1 = createRequire(import.meta.url);
199
+
200
+ function __require$1() {
201
+ return require$1('node:process');
202
+ }
203
+
176
204
  var help = {};
177
205
 
178
206
  var hasRequiredHelp;
@@ -751,11 +779,11 @@ var hasRequiredCommand;
751
779
  function requireCommand() {
752
780
  if (hasRequiredCommand) return command;
753
781
  hasRequiredCommand = 1;
754
- const EventEmitter = require$$0.EventEmitter;
755
- const childProcess = require$$1;
756
- const path = path__default;
757
- const fs = fs$2;
758
- const process = process$1;
782
+ const EventEmitter = __require$5().EventEmitter;
783
+ const childProcess = __require$4();
784
+ const path = __require$3();
785
+ const fs = __require$2();
786
+ const process = __require$1();
759
787
  const {Argument: Argument, humanReadableArgName: humanReadableArgName} = requireArgument();
760
788
  const {CommanderError: CommanderError} = requireError();
761
789
  const {Help: Help, stripColor: stripColor} = requireHelp();
@@ -1605,7 +1633,7 @@ function requireCommand() {
1605
1633
  return arg.length > 1 && arg[0] === '-';
1606
1634
  }
1607
1635
  const negativeNumberArg = arg => {
1608
- if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg)) return false;
1636
+ if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
1609
1637
  return !this._getCommandAndAncestors().some(cmd => cmd.options.map(opt => opt.short).some(short => /^-\d$/.test(short)));
1610
1638
  };
1611
1639
  let activeVariadicOption = null;
@@ -2127,6 +2155,12 @@ const {program: program$1, createCommand: createCommand, createArgument: createA
2127
2155
 
2128
2156
  var main$3 = {};
2129
2157
 
2158
+ const require = createRequire(import.meta.url);
2159
+
2160
+ function __require() {
2161
+ return require('node:util');
2162
+ }
2163
+
2130
2164
  var is$2 = {};
2131
2165
 
2132
2166
  var hasRequiredIs$2;
@@ -5334,7 +5368,7 @@ function requireRil() {
5334
5368
  Object.defineProperty(ril, '__esModule', {
5335
5369
  value: true
5336
5370
  });
5337
- const util_1 = require$$0$1;
5371
+ const util_1 = require$$0;
5338
5372
  const api_1 = requireApi$2();
5339
5373
  class MessageBuffer extends api_1.AbstractMessageBuffer {
5340
5374
  constructor(encoding = 'utf-8') {
@@ -5522,7 +5556,7 @@ function requireMain$3() {
5522
5556
  exports.createMessageConnection = exports.createServerSocketTransport = exports.createClientSocketTransport = exports.createServerPipeTransport = exports.createClientPipeTransport = exports.generateRandomPipeName = exports.StreamMessageWriter = exports.StreamMessageReader = exports.SocketMessageWriter = exports.SocketMessageReader = exports.PortMessageWriter = exports.PortMessageReader = exports.IPCMessageWriter = exports.IPCMessageReader = void 0;
5523
5557
  const ril_1 = requireRil();
5524
5558
  ril_1.default.install();
5525
- const path = require$$1$1;
5559
+ const path = require$$1;
5526
5560
  const os = require$$2;
5527
5561
  const crypto_1 = crypto;
5528
5562
  const net_1 = require$$4;
@@ -11133,9 +11167,9 @@ function requireFiles() {
11133
11167
  value: true
11134
11168
  });
11135
11169
  files.resolveModulePath = files.FileSystem = files.resolveGlobalYarnPath = files.resolveGlobalNodePath = files.resolve = files.uriToFilePath = void 0;
11136
- const url = require$$0$2;
11137
- const path = require$$1$1;
11138
- const fs = require$$0$3;
11170
+ const url = require$$0$1;
11171
+ const path = require$$1;
11172
+ const fs = require$$0$2;
11139
11173
  const child_process_1 = require$$3;
11140
11174
  function uriToFilePath(uri) {
11141
11175
  let parsed = url.parse(uri);
@@ -11468,7 +11502,7 @@ function requireMain() {
11468
11502
  value: true
11469
11503
  });
11470
11504
  exports.createConnection = exports.Files = void 0;
11471
- const node_util_1 = require$$0$4;
11505
+ const node_util_1 = __require();
11472
11506
  const Is = requireIs$2();
11473
11507
  const server_1 = requireServer();
11474
11508
  const fm = requireFiles();
@@ -11902,7 +11936,7 @@ var hasRequiredPolyfills;
11902
11936
  function requirePolyfills() {
11903
11937
  if (hasRequiredPolyfills) return polyfills;
11904
11938
  hasRequiredPolyfills = 1;
11905
- var constants = require$$0$5;
11939
+ var constants = require$$0$3;
11906
11940
  var origCwd = process.cwd;
11907
11941
  var cwd = null;
11908
11942
  var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -12174,7 +12208,7 @@ var hasRequiredLegacyStreams;
12174
12208
  function requireLegacyStreams() {
12175
12209
  if (hasRequiredLegacyStreams) return legacyStreams;
12176
12210
  hasRequiredLegacyStreams = 1;
12177
- var Stream = require$$0$6.Stream;
12211
+ var Stream = require$$0$4.Stream;
12178
12212
  legacyStreams = legacy;
12179
12213
  function legacy(fs) {
12180
12214
  return {
@@ -12298,11 +12332,11 @@ var hasRequiredGracefulFs;
12298
12332
  function requireGracefulFs() {
12299
12333
  if (hasRequiredGracefulFs) return gracefulFs;
12300
12334
  hasRequiredGracefulFs = 1;
12301
- var fs = require$$0$3;
12335
+ var fs = require$$0$2;
12302
12336
  var polyfills = requirePolyfills();
12303
12337
  var legacy = requireLegacyStreams();
12304
12338
  var clone = requireClone();
12305
- var util = require$$0$1;
12339
+ var util = require$$0;
12306
12340
  var gracefulQueue;
12307
12341
  var previousSymbol;
12308
12342
  if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
@@ -12701,7 +12735,7 @@ var hasRequiredUtils$1;
12701
12735
  function requireUtils$1() {
12702
12736
  if (hasRequiredUtils$1) return utils$1;
12703
12737
  hasRequiredUtils$1 = 1;
12704
- const path = require$$1$1;
12738
+ const path = require$$1;
12705
12739
  utils$1.checkPath = function checkPath(pth) {
12706
12740
  if (process.platform === 'win32') {
12707
12741
  const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
@@ -12834,7 +12868,7 @@ function requireStat() {
12834
12868
  if (hasRequiredStat) return stat;
12835
12869
  hasRequiredStat = 1;
12836
12870
  const fs = requireFs();
12837
- const path = require$$1$1;
12871
+ const path = require$$1;
12838
12872
  const u = requireUniversalify().fromPromise;
12839
12873
  function getStats(src, dest, opts) {
12840
12874
  const statFunc = opts.dereference ? file => fs.stat(file, {
@@ -13020,7 +13054,7 @@ function requireCopy$1() {
13020
13054
  if (hasRequiredCopy$1) return copy_1;
13021
13055
  hasRequiredCopy$1 = 1;
13022
13056
  const fs = requireFs();
13023
- const path = require$$1$1;
13057
+ const path = require$$1;
13024
13058
  const {mkdirs: mkdirs} = requireMkdirs();
13025
13059
  const {pathExists: pathExists} = requirePathExists();
13026
13060
  const {utimesMillis: utimesMillis} = requireUtimes();
@@ -13145,7 +13179,7 @@ function requireCopySync() {
13145
13179
  if (hasRequiredCopySync) return copySync_1;
13146
13180
  hasRequiredCopySync = 1;
13147
13181
  const fs = requireGracefulFs();
13148
- const path = require$$1$1;
13182
+ const path = require$$1;
13149
13183
  const mkdirsSync = requireMkdirs().mkdirsSync;
13150
13184
  const utimesMillisSync = requireUtimes().utimesMillisSync;
13151
13185
  const stat = requireStat();
@@ -13322,7 +13356,7 @@ function requireEmpty() {
13322
13356
  hasRequiredEmpty = 1;
13323
13357
  const u = requireUniversalify().fromPromise;
13324
13358
  const fs = requireFs();
13325
- const path = require$$1$1;
13359
+ const path = require$$1;
13326
13360
  const mkdir = requireMkdirs();
13327
13361
  const remove = requireRemove();
13328
13362
  const emptyDir = u(async function emptyDir(dir) {
@@ -13363,7 +13397,7 @@ function requireFile() {
13363
13397
  if (hasRequiredFile) return file$1;
13364
13398
  hasRequiredFile = 1;
13365
13399
  const u = requireUniversalify().fromPromise;
13366
- const path = require$$1$1;
13400
+ const path = require$$1;
13367
13401
  const fs = requireFs();
13368
13402
  const mkdir = requireMkdirs();
13369
13403
  async function createFile(file) {
@@ -13422,7 +13456,7 @@ function requireLink() {
13422
13456
  if (hasRequiredLink) return link;
13423
13457
  hasRequiredLink = 1;
13424
13458
  const u = requireUniversalify().fromPromise;
13425
- const path = require$$1$1;
13459
+ const path = require$$1;
13426
13460
  const fs = requireFs();
13427
13461
  const mkdir = requireMkdirs();
13428
13462
  const {pathExists: pathExists} = requirePathExists();
@@ -13479,7 +13513,7 @@ var hasRequiredSymlinkPaths;
13479
13513
  function requireSymlinkPaths() {
13480
13514
  if (hasRequiredSymlinkPaths) return symlinkPaths_1;
13481
13515
  hasRequiredSymlinkPaths = 1;
13482
- const path = require$$1$1;
13516
+ const path = require$$1;
13483
13517
  const fs = requireFs();
13484
13518
  const {pathExists: pathExists} = requirePathExists();
13485
13519
  const u = requireUniversalify().fromPromise;
@@ -13592,7 +13626,7 @@ function requireSymlink() {
13592
13626
  if (hasRequiredSymlink) return symlink;
13593
13627
  hasRequiredSymlink = 1;
13594
13628
  const u = requireUniversalify().fromPromise;
13595
- const path = require$$1$1;
13629
+ const path = require$$1;
13596
13630
  const fs = requireFs();
13597
13631
  const {mkdirs: mkdirs, mkdirsSync: mkdirsSync} = requireMkdirs();
13598
13632
  const {symlinkPaths: symlinkPaths, symlinkPathsSync: symlinkPathsSync} = requireSymlinkPaths();
@@ -13704,7 +13738,7 @@ function requireJsonfile$1() {
13704
13738
  try {
13705
13739
  _fs = requireGracefulFs();
13706
13740
  } catch (_) {
13707
- _fs = require$$0$3;
13741
+ _fs = require$$0$2;
13708
13742
  }
13709
13743
  const universalify = requireUniversalify();
13710
13744
  const {stringify: stringify, stripBom: stripBom} = requireUtils();
@@ -13799,7 +13833,7 @@ function requireOutputFile() {
13799
13833
  hasRequiredOutputFile = 1;
13800
13834
  const u = requireUniversalify().fromPromise;
13801
13835
  const fs = requireFs();
13802
- const path = require$$1$1;
13836
+ const path = require$$1;
13803
13837
  const mkdir = requireMkdirs();
13804
13838
  const pathExists = requirePathExists().pathExists;
13805
13839
  async function outputFile(file, data, encoding = 'utf-8') {
@@ -13886,7 +13920,7 @@ function requireMove$1() {
13886
13920
  if (hasRequiredMove$1) return move_1;
13887
13921
  hasRequiredMove$1 = 1;
13888
13922
  const fs = requireFs();
13889
- const path = require$$1$1;
13923
+ const path = require$$1;
13890
13924
  const {copy: copy} = requireCopy();
13891
13925
  const {remove: remove} = requireRemove();
13892
13926
  const {mkdirp: mkdirp} = requireMkdirs();
@@ -13941,7 +13975,7 @@ function requireMoveSync() {
13941
13975
  if (hasRequiredMoveSync) return moveSync_1;
13942
13976
  hasRequiredMoveSync = 1;
13943
13977
  const fs = requireGracefulFs();
13944
- const path = require$$1$1;
13978
+ const path = require$$1;
13945
13979
  const copySync = requireCopy().copySync;
13946
13980
  const removeSync = requireRemove().removeSync;
13947
13981
  const mkdirpSync = requireMkdirs().mkdirpSync;
@@ -15226,6 +15260,9 @@ function requireIdentifiers() {
15226
15260
  hasRequiredIdentifiers = 1;
15227
15261
  const numeric = /^[0-9]+$/;
15228
15262
  const compareIdentifiers = (a, b) => {
15263
+ if (typeof a === 'number' && typeof b === 'number') {
15264
+ return a === b ? 0 : a < b ? -1 : 1;
15265
+ }
15229
15266
  const anum = numeric.test(a);
15230
15267
  const bnum = numeric.test(b);
15231
15268
  if (anum && bnum) {
@@ -15333,7 +15370,25 @@ function requireSemver$1() {
15333
15370
  if (!(other instanceof SemVer)) {
15334
15371
  other = new SemVer(other, this.options);
15335
15372
  }
15336
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
15373
+ if (this.major < other.major) {
15374
+ return -1;
15375
+ }
15376
+ if (this.major > other.major) {
15377
+ return 1;
15378
+ }
15379
+ if (this.minor < other.minor) {
15380
+ return -1;
15381
+ }
15382
+ if (this.minor > other.minor) {
15383
+ return 1;
15384
+ }
15385
+ if (this.patch < other.patch) {
15386
+ return -1;
15387
+ }
15388
+ if (this.patch > other.patch) {
15389
+ return 1;
15390
+ }
15391
+ return 0;
15337
15392
  }
15338
15393
  comparePre(other) {
15339
15394
  if (!(other instanceof SemVer)) {
@@ -16161,6 +16216,7 @@ function requireRange() {
16161
16216
  return result;
16162
16217
  };
16163
16218
  const parseComparator = (comp, options) => {
16219
+ comp = comp.replace(re[t.BUILD], '');
16164
16220
  debug('comp', comp, options);
16165
16221
  comp = replaceCarets(comp, options);
16166
16222
  debug('caret', comp);
@@ -18487,7 +18543,7 @@ class NodeTsServerProcessFactory {
18487
18543
  if (useIpc) {
18488
18544
  runtimeArgs.push('--useNodeIpc');
18489
18545
  }
18490
- const childProcess = require$$1.fork(tsServerPath, runtimeArgs, {
18546
+ const childProcess = ChildProcess.fork(tsServerPath, runtimeArgs, {
18491
18547
  silent: true,
18492
18548
  cwd: undefined,
18493
18549
  env: generatePatchedEnv(process.env, tsServerPath),
@@ -19397,25 +19453,23 @@ class TsClient {
19397
19453
  }
19398
19454
  }
19399
19455
 
19400
- const pDebounce = (function_, wait, options = {}) => {
19456
+ const pDebounce = (functionToDebounce, wait, options = {}) => {
19401
19457
  if (!Number.isFinite(wait)) {
19402
19458
  throw new TypeError('Expected `wait` to be a finite number');
19403
19459
  }
19404
19460
  let leadingValue;
19405
19461
  let timeout;
19406
- let resolveList = [];
19407
- let rejectList = [];
19462
+ let promiseHandlers = [];
19408
19463
  const onAbort = () => {
19409
19464
  clearTimeout(timeout);
19410
- timeout = null;
19465
+ timeout = undefined;
19411
19466
  try {
19412
19467
  options.signal?.throwIfAborted();
19413
19468
  } catch (error) {
19414
- for (const reject of rejectList) {
19469
+ for (const {reject: reject} of promiseHandlers) {
19415
19470
  reject(error);
19416
19471
  }
19417
- resolveList = [];
19418
- rejectList = [];
19472
+ promiseHandlers = [];
19419
19473
  }
19420
19474
  };
19421
19475
  return function(...arguments_) {
@@ -19429,18 +19483,16 @@ const pDebounce = (function_, wait, options = {}) => {
19429
19483
  const shouldCallNow = options.before && !timeout;
19430
19484
  clearTimeout(timeout);
19431
19485
  timeout = setTimeout(async () => {
19432
- timeout = null;
19433
- const currentResolveList = resolveList;
19434
- const currentRejectList = rejectList;
19435
- resolveList = [];
19436
- rejectList = [];
19486
+ timeout = undefined;
19487
+ const currentHandlers = promiseHandlers;
19488
+ promiseHandlers = [];
19437
19489
  try {
19438
- const result = options.before ? leadingValue : await function_.apply(this, arguments_);
19439
- for (const resolveFunction of currentResolveList) {
19490
+ const result = options.before ? leadingValue : await functionToDebounce.apply(this, arguments_);
19491
+ for (const {resolve: resolveFunction} of currentHandlers) {
19440
19492
  resolveFunction(result);
19441
19493
  }
19442
19494
  } catch (error) {
19443
- for (const rejectFunction of currentRejectList) {
19495
+ for (const {reject: rejectFunction} of currentHandlers) {
19444
19496
  rejectFunction(error);
19445
19497
  }
19446
19498
  }
@@ -19450,16 +19502,18 @@ const pDebounce = (function_, wait, options = {}) => {
19450
19502
  if (shouldCallNow) {
19451
19503
  (async () => {
19452
19504
  try {
19453
- leadingValue = await function_.apply(this, arguments_);
19505
+ leadingValue = await functionToDebounce.apply(this, arguments_);
19454
19506
  resolve(leadingValue);
19455
19507
  } catch (error) {
19456
19508
  reject(error);
19457
19509
  }
19458
19510
  })();
19459
19511
  } else {
19460
- resolveList.push(resolve);
19461
- rejectList.push(reject);
19462
- if (options.signal && resolveList.length === 1) {
19512
+ promiseHandlers.push({
19513
+ resolve: resolve,
19514
+ reject: reject
19515
+ });
19516
+ if (options.signal && promiseHandlers.length === 1) {
19463
19517
  options.signal.addEventListener('abort', onAbort, {
19464
19518
  once: true
19465
19519
  });
@@ -19469,14 +19523,54 @@ const pDebounce = (function_, wait, options = {}) => {
19469
19523
  };
19470
19524
  };
19471
19525
 
19472
- pDebounce.promise = function_ => {
19526
+ pDebounce.promise = (function_, options = {}) => {
19473
19527
  let currentPromise;
19528
+ let queuedCall;
19474
19529
  return async function(...arguments_) {
19475
19530
  if (currentPromise) {
19476
- return currentPromise;
19531
+ if (!options.after) {
19532
+ return currentPromise;
19533
+ }
19534
+ queuedCall ??= {
19535
+ resolvers: []
19536
+ };
19537
+ queuedCall.arguments = arguments_;
19538
+ queuedCall.context = this;
19539
+ return new Promise((resolve, reject) => {
19540
+ queuedCall.resolvers.push({
19541
+ resolve: resolve,
19542
+ reject: reject
19543
+ });
19544
+ });
19477
19545
  }
19546
+ currentPromise = (async () => {
19547
+ let result;
19548
+ let initialError;
19549
+ try {
19550
+ result = await function_.apply(this, arguments_);
19551
+ } catch (error) {
19552
+ initialError = error;
19553
+ }
19554
+ while (queuedCall) {
19555
+ const call = queuedCall;
19556
+ queuedCall = undefined;
19557
+ try {
19558
+ const queuedResult = await function_.apply(call.context, call.arguments);
19559
+ for (const {resolve: resolve} of call.resolvers) {
19560
+ resolve(queuedResult);
19561
+ }
19562
+ } catch (error) {
19563
+ for (const {reject: reject} of call.resolvers) {
19564
+ reject(error);
19565
+ }
19566
+ }
19567
+ }
19568
+ if (initialError) {
19569
+ throw initialError;
19570
+ }
19571
+ return result;
19572
+ })();
19478
19573
  try {
19479
- currentPromise = function_.apply(this, arguments_);
19480
19574
  return await currentPromise;
19481
19575
  } finally {
19482
19576
  currentPromise = undefined;
@@ -21348,8 +21442,9 @@ function areFileConfigurationsEqual(a, b) {
21348
21442
  }
21349
21443
 
21350
21444
  class FileConfigurationManager {
21351
- constructor(client, onCaseInsensitiveFileSystem) {
21445
+ constructor(client, lspClient, onCaseInsensitiveFileSystem) {
21352
21446
  this.client = client;
21447
+ this.lspClient = lspClient;
21353
21448
  this.tsPreferences = deepmerge({}, DEFAULT_TSSERVER_PREFERENCES);
21354
21449
  this.workspaceConfiguration = deepmerge({}, DEFAULT_WORKSPACE_CONFIGURATION);
21355
21450
  this.formatOptions = new ResourceMap(undefined, {
@@ -21394,7 +21489,19 @@ class FileConfigurationManager {
21394
21489
  });
21395
21490
  }
21396
21491
  async ensureConfigurationForDocument(document, token) {
21397
- return this.ensureConfigurationOptions(document, undefined, token);
21492
+ const formattingOptions = await this.getFormattingOptions(document);
21493
+ return this.ensureConfigurationOptions(document, formattingOptions, token);
21494
+ }
21495
+ async getFormattingOptions(document) {
21496
+ const formatConfiguration = await this.lspClient.getWorkspaceConfiguration(document.uri.toString(), 'formattingOptions') || {};
21497
+ const options = {};
21498
+ if (typeof formatConfiguration.tabSize === 'number') {
21499
+ options.tabSize = formatConfiguration.tabSize;
21500
+ }
21501
+ if (typeof formatConfiguration.insertSpaces === 'boolean') {
21502
+ options.insertSpaces = formatConfiguration.insertSpaces;
21503
+ }
21504
+ return options;
21398
21505
  }
21399
21506
  async ensureConfigurationOptions(document, options, token) {
21400
21507
  const currentOptions = this.getFileOptions(document, options);
@@ -21875,8 +21982,8 @@ function requirePosix() {
21875
21982
  value: true
21876
21983
  });
21877
21984
  posix.sync = posix.isexe = void 0;
21878
- const fs_1 = require$$0$3;
21879
- const promises_1 = require$$1$2;
21985
+ const fs_1 = require$$0$2;
21986
+ const promises_1 = require$$1$1;
21880
21987
  const isexe = async (path, options = {}) => {
21881
21988
  const {ignoreErrors: ignoreErrors = false} = options;
21882
21989
  try {
@@ -21931,8 +22038,8 @@ function requireWin32() {
21931
22038
  value: true
21932
22039
  });
21933
22040
  win32.sync = win32.isexe = void 0;
21934
- const fs_1 = require$$0$3;
21935
- const promises_1 = require$$1$2;
22041
+ const fs_1 = require$$0$2;
22042
+ const promises_1 = require$$1$1;
21936
22043
  const isexe = async (path, options = {}) => {
21937
22044
  const {ignoreErrors: ignoreErrors = false} = options;
21938
22045
  try {
@@ -22052,7 +22159,7 @@ function requireLib() {
22052
22159
  if (hasRequiredLib) return lib;
22053
22160
  hasRequiredLib = 1;
22054
22161
  const {isexe: isexe, sync: isexeSync} = requireCjs();
22055
- const {join: join, delimiter: delimiter, sep: sep, posix: posix} = require$$1$1;
22162
+ const {join: join, delimiter: delimiter, sep: sep, posix: posix} = require$$1;
22056
22163
  const isWindows = process.platform === 'win32';
22057
22164
  const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'));
22058
22165
  const rRel = new RegExp(`^\\.${rSlash.source}`);
@@ -23066,7 +23173,7 @@ class LspServer {
23066
23173
  this.referencesCodeLensProvider = null;
23067
23174
  this.logger = new PrefixingLogger(options.logger, '[lspserver]');
23068
23175
  this.tsClient = new TsClient(onCaseInsensitiveFileSystem(), this.logger, options.lspClient);
23069
- this.fileConfigurationManager = new FileConfigurationManager(this.tsClient, onCaseInsensitiveFileSystem());
23176
+ this.fileConfigurationManager = new FileConfigurationManager(this.tsClient, this.options.lspClient, onCaseInsensitiveFileSystem());
23070
23177
  this.commandManager = new CommandManager;
23071
23178
  this.diagnosticsManager = new DiagnosticsManager(diagnostics => this.options.lspClient.publishDiagnostics(diagnostics), this.tsClient, this.features, this.logger);
23072
23179
  this.codeActionsManager = new CodeActionManager(this.tsClient, this.fileConfigurationManager, this.commandManager, this.diagnosticsManager, this.features);
@@ -23477,7 +23584,6 @@ class LspServer {
23477
23584
  const uri = this.tsClient.toResourceUri(cachedData.file);
23478
23585
  document = this.tsClient.toOpenDocument(uri);
23479
23586
  if (document) {
23480
- await this.fileConfigurationManager.ensureConfigurationForDocument(document, token);
23481
23587
  const response = await this.tsClient.interruptGetErr(() => this.tsClient.execute(CommandTypes.CompletionDetails, cachedData, token));
23482
23588
  if (response.type !== 'response' || !response.body?.length) {
23483
23589
  return item;
@@ -23664,14 +23770,17 @@ class LspServer {
23664
23770
  skipDestructiveCodeActions = documentHasErrors;
23665
23771
  mode = OrganizeImportsMode.SortAndCombine;
23666
23772
  }
23667
- const response = await this.tsClient.interruptGetErr(() => this.tsClient.execute(CommandTypes.OrganizeImports, {
23668
- scope: {
23669
- type: 'file',
23670
- args: fileRangeArgs
23671
- },
23672
- skipDestructiveCodeActions: skipDestructiveCodeActions,
23673
- mode: mode
23674
- }, token));
23773
+ const response = await this.tsClient.interruptGetErr(async () => {
23774
+ await this.fileConfigurationManager.ensureConfigurationForDocument(document, token);
23775
+ return this.tsClient.execute(CommandTypes.OrganizeImports, {
23776
+ scope: {
23777
+ type: 'file',
23778
+ args: fileRangeArgs
23779
+ },
23780
+ skipDestructiveCodeActions: skipDestructiveCodeActions,
23781
+ mode: mode
23782
+ }, token);
23783
+ });
23675
23784
  if (response.type === 'response' && response.body) {
23676
23785
  actions.push(...provideOrganizeImports(command, response, this.tsClient));
23677
23786
  }
@@ -23738,6 +23847,7 @@ class LspServer {
23738
23847
  const additionalArguments = params.arguments[1] || {};
23739
23848
  const body = await this.tsClient.interruptGetErr(async () => {
23740
23849
  await this.fileConfigurationManager.ensureConfigurationForDocument(document);
23850
+ const mode = additionalArguments.mode ?? (additionalArguments.skipDestructiveCodeActions ? OrganizeImportsMode.SortAndCombine : OrganizeImportsMode.All);
23741
23851
  const response = await this.tsClient.execute(CommandTypes.OrganizeImports, {
23742
23852
  scope: {
23743
23853
  type: 'file',
@@ -23746,7 +23856,7 @@ class LspServer {
23746
23856
  }
23747
23857
  },
23748
23858
  skipDestructiveCodeActions: additionalArguments.skipDestructiveCodeActions,
23749
- mode: additionalArguments.skipDestructiveCodeActions ? OrganizeImportsMode.SortAndCombine : OrganizeImportsMode.All
23859
+ mode: mode
23750
23860
  }, token);
23751
23861
  if (response.type !== 'response') {
23752
23862
  return;
@@ -24096,6 +24206,12 @@ class LspClientImpl {
24096
24206
  logMessage(args) {
24097
24207
  this.connection.sendNotification(mainExports$2.LogMessageNotification.type, args);
24098
24208
  }
24209
+ async getWorkspaceConfiguration(scopeUri, section) {
24210
+ return await this.connection.workspace.getConfiguration({
24211
+ scopeUri: scopeUri,
24212
+ section: section
24213
+ });
24214
+ }
24099
24215
  async applyWorkspaceEdit(params) {
24100
24216
  return this.connection.workspace.applyEdit(params);
24101
24217
  }