volar-service-typescript 0.0.43 → 0.0.44

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.
@@ -1,5 +1,5 @@
1
1
  import type { FormattingOptions, ServiceContext } from '@volar/language-service';
2
2
  import type * as ts from 'typescript';
3
3
  import type { TextDocument } from 'vscode-languageserver-textdocument';
4
- export declare function getFormatCodeSettings(ctx: ServiceContext, document: TextDocument, options?: FormattingOptions): Promise<ts.FormatCodeSettings>;
4
+ export declare function getFormatCodeSettings(ctx: ServiceContext, document: TextDocument, options: FormattingOptions | undefined): Promise<ts.FormatCodeSettings>;
5
5
  //# sourceMappingURL=getFormatCodeSettings.d.ts.map
@@ -8,6 +8,7 @@ async function getUserPreferences(ctx, document) {
8
8
  if (ctx.language.typescript) {
9
9
  currentDirectory = ctx.language.typescript.languageServiceHost.getCurrentDirectory();
10
10
  }
11
+ const documentUri = ctx.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
11
12
  const config = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document)) ?? {};
12
13
  const preferencesConfig = config?.preferences ?? {};
13
14
  const preferences = {
@@ -16,7 +17,7 @@ async function getUserPreferences(ctx, document) {
16
17
  importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
17
18
  importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
18
19
  jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
19
- allowTextChangesInNewFiles: document.uri.startsWith('file://'),
20
+ allowTextChangesInNewFiles: documentUri.startsWith('file://'),
20
21
  providePrefixAndSuffixTextForRename: (preferencesConfig.renameShorthandProperties ?? true) === false ? false : (preferencesConfig.useAliasesForRenames ?? true),
21
22
  allowRenameOfImportPath: true,
22
23
  includeAutomaticOptionalChainCompletions: config.suggest?.includeAutomaticOptionalChainCompletions ?? true,
@@ -126,7 +126,6 @@ function create(ts, { isValidationEnabled = async (document, context) => {
126
126
  return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
127
127
  }
128
128
  }
129
- throw new Error(`getTextDocument: uri not found: ${uri}`);
130
129
  },
131
130
  };
132
131
  const getCodeActions = codeActions.register(ctx);
@@ -134,6 +133,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
134
133
  const getDocumentSemanticTokens = semanticTokens.register(ts, ctx);
135
134
  /* typescript-language-features is hardcode true */
136
135
  const renameInfoOptions = { allowRenameOfImportPath: true };
136
+ let formattingOptions;
137
137
  return {
138
138
  provide: {
139
139
  'typescript/languageService': () => languageService,
@@ -142,6 +142,14 @@ function create(ts, { isValidationEnabled = async (document, context) => {
142
142
  dispose() {
143
143
  languageService.dispose();
144
144
  },
145
+ provideDocumentFormattingEdits(_document, _range, options) {
146
+ formattingOptions = options;
147
+ return undefined;
148
+ },
149
+ provideOnTypeFormattingEdits(_document, _position, _key, options) {
150
+ formattingOptions = options;
151
+ return undefined;
152
+ },
145
153
  async provideCompletionItems(document, position, completeContext, token) {
146
154
  if (!isSemanticDocument(document)) {
147
155
  return;
@@ -182,7 +190,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
182
190
  const { fileName, offset } = data;
183
191
  const document = ctx.getTextDocument(data.uri);
184
192
  const [formatOptions, preferences] = await Promise.all([
185
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
193
+ (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
186
194
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
187
195
  ]);
188
196
  const details = (0, shared_1.safeCall)(() => ctx.languageService.getCompletionEntryDetails(fileName, offset, data.originalItem.name, formatOptions, data.originalItem.source, preferences, data.originalItem.data));
@@ -281,7 +289,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
281
289
  }
282
290
  if (renameInfo.fileToRename) {
283
291
  const [formatOptions, preferences] = await Promise.all([
284
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
292
+ (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
285
293
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
286
294
  ]);
287
295
  return renameFile(renameInfo.fileToRename, newName, formatOptions, preferences);
@@ -321,12 +329,12 @@ function create(ts, { isValidationEnabled = async (document, context) => {
321
329
  return;
322
330
  }
323
331
  return worker(token, () => {
324
- return getCodeActions(document, range, context);
332
+ return getCodeActions(document, range, context, formattingOptions);
325
333
  });
326
334
  },
327
335
  async resolveCodeAction(codeAction, token) {
328
336
  return await worker(token, () => {
329
- return doCodeActionResolve(codeAction);
337
+ return doCodeActionResolve(codeAction, formattingOptions);
330
338
  }) ?? codeAction;
331
339
  },
332
340
  provideInlayHints(document, range, token) {
@@ -536,7 +544,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
536
544
  return worker(token, async () => {
537
545
  const document = ctx.getTextDocument(oldUri);
538
546
  const [formatOptions, preferences] = await Promise.all([
539
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
547
+ (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
540
548
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
541
549
  ]);
542
550
  const fileToRename = ctx.uriToFileName(oldUri);
@@ -24,5 +24,5 @@ export interface OrganizeImportsData {
24
24
  fileName: string;
25
25
  }
26
26
  export type Data = FixAllData | RefactorData | OrganizeImportsData;
27
- export declare function register(ctx: SharedContext): (document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext) => Promise<vscode.CodeAction[]>;
27
+ export declare function register(ctx: SharedContext): (document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, formattingOptions: vscode.FormattingOptions | undefined) => Promise<vscode.CodeAction[]>;
28
28
  //# sourceMappingURL=codeAction.d.ts.map
@@ -7,16 +7,32 @@ const shared_1 = require("../shared");
7
7
  const fixNames = require("../utils/fixNames");
8
8
  const codeActionResolve_1 = require("./codeActionResolve");
9
9
  const lspConverters_1 = require("../utils/lspConverters");
10
+ const renameCommandRefactors = new Set([
11
+ 'refactor.rewrite.property.generateAccessors',
12
+ 'refactor.extract.type',
13
+ 'refactor.extract.interface',
14
+ 'refactor.extract.typedef',
15
+ 'refactor.extract.constant',
16
+ 'refactor.extract.function',
17
+ ]);
10
18
  function register(ctx) {
11
19
  let resolveCommandSupport = ctx.env.clientCapabilities?.textDocument?.codeAction?.resolveSupport?.properties?.includes('command');
12
20
  let resolveEditSupport = ctx.env.clientCapabilities?.textDocument?.codeAction?.resolveSupport?.properties?.includes('edit');
21
+ let loged = false;
22
+ const wranUnsupportResolve = () => {
23
+ if (loged) {
24
+ return;
25
+ }
26
+ loged = true;
27
+ console.warn('[volar-service-typescript] The language client lacks support for the command/edit properties in the resolve code action. Therefore, the code action resolve is pre-calculated.');
28
+ };
13
29
  if (!ctx.env.clientCapabilities) {
14
30
  resolveCommandSupport = true;
15
31
  resolveEditSupport = true;
16
32
  }
17
- return async (document, range, context) => {
33
+ return async (document, range, context, formattingOptions) => {
18
34
  const [formatOptions, preferences] = await Promise.all([
19
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
35
+ (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
20
36
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
21
37
  ]);
22
38
  const fileName = ctx.uriToFileName(document.uri);
@@ -63,6 +79,7 @@ function register(ctx) {
63
79
  action.data = data;
64
80
  }
65
81
  else {
82
+ wranUnsupportResolve();
66
83
  (0, codeActionResolve_1.resolveOrganizeImportsCodeAction)(ctx, action, data, formatOptions, preferences);
67
84
  }
68
85
  result.push(action);
@@ -87,6 +104,7 @@ function register(ctx) {
87
104
  action.data = data;
88
105
  }
89
106
  else {
107
+ wranUnsupportResolve();
90
108
  (0, codeActionResolve_1.resolveFixAllCodeAction)(ctx, action, data, formatOptions, preferences);
91
109
  }
92
110
  result.push(action);
@@ -115,6 +133,7 @@ function register(ctx) {
115
133
  action.data = data;
116
134
  }
117
135
  else {
136
+ wranUnsupportResolve();
118
137
  (0, codeActionResolve_1.resolveFixAllCodeAction)(ctx, action, data, formatOptions, preferences);
119
138
  }
120
139
  result.push(action);
@@ -140,6 +159,7 @@ function register(ctx) {
140
159
  action.data = data;
141
160
  }
142
161
  else {
162
+ wranUnsupportResolve();
143
163
  (0, codeActionResolve_1.resolveFixAllCodeAction)(ctx, action, data, formatOptions, preferences);
144
164
  }
145
165
  result.push(action);
@@ -194,6 +214,7 @@ function register(ctx) {
194
214
  fixAll.data = data;
195
215
  }
196
216
  else {
217
+ wranUnsupportResolve();
197
218
  (0, codeActionResolve_1.resolveFixAllCodeAction)(ctx, fixAll, data, formatOptions, preferences);
198
219
  }
199
220
  fixAll.diagnostics = diagnostics;
@@ -222,10 +243,15 @@ function register(ctx) {
222
243
  refactorName: refactor.name,
223
244
  actionName: action.name,
224
245
  };
225
- if (resolveCommandSupport && resolveEditSupport) {
246
+ const hasCommand = renameCommandRefactors.has(action.kind);
247
+ if (hasCommand && resolveCommandSupport && resolveEditSupport) {
248
+ codeAction.data = data;
249
+ }
250
+ else if (!hasCommand && resolveEditSupport) {
226
251
  codeAction.data = data;
227
252
  }
228
- else if (!codeAction.disabled && document) {
253
+ else if (!codeAction.disabled) {
254
+ wranUnsupportResolve();
229
255
  (0, codeActionResolve_1.resolveRefactorCodeAction)(ctx, codeAction, data, document, formatOptions, preferences);
230
256
  }
231
257
  codeActions.push(codeAction);
@@ -3,7 +3,7 @@ import type * as ts from 'typescript';
3
3
  import type { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  import type { SharedContext } from './types';
5
5
  import type { Data, FixAllData, RefactorData } from './codeAction';
6
- export declare function register(ctx: SharedContext): (codeAction: vscode.CodeAction) => Promise<vscode.CodeAction>;
6
+ export declare function register(ctx: SharedContext): (codeAction: vscode.CodeAction, formattingOptions: vscode.FormattingOptions | undefined) => Promise<vscode.CodeAction>;
7
7
  export declare function resolveFixAllCodeAction(ctx: SharedContext, codeAction: vscode.CodeAction, data: FixAllData, formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences): void;
8
8
  export declare function resolveRefactorCodeAction(ctx: SharedContext, codeAction: vscode.CodeAction, data: RefactorData, document: TextDocument, formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences): void;
9
9
  export declare function resolveOrganizeImportsCodeAction(ctx: SharedContext, codeAction: vscode.CodeAction, data: Data, formatOptions: ts.FormatCodeSettings, preferences: ts.UserPreferences): void;
@@ -6,11 +6,11 @@ const getUserPreferences_1 = require("../configs/getUserPreferences");
6
6
  const shared_1 = require("../shared");
7
7
  const lspConverters_1 = require("../utils/lspConverters");
8
8
  function register(ctx) {
9
- return async (codeAction) => {
9
+ return async (codeAction, formattingOptions) => {
10
10
  const data = codeAction.data;
11
11
  const document = ctx.getTextDocument(data.uri);
12
12
  const [formatOptions, preferences] = await Promise.all([
13
- (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document),
13
+ (0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
14
14
  (0, getUserPreferences_1.getUserPreferences)(ctx, document),
15
15
  ]);
16
16
  if (data?.type === 'fixAll') {
@@ -4,7 +4,7 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  export type SharedContext = ServiceContext & {
5
5
  languageServiceHost: ts.LanguageServiceHost;
6
6
  languageService: ts.LanguageService;
7
- getTextDocument: (uri: string) => TextDocument;
7
+ getTextDocument: (uri: string) => TextDocument | undefined;
8
8
  uriToFileName: (uri: string) => string;
9
9
  fileNameToUri: (fileName: string) => string;
10
10
  };
@@ -2,26 +2,26 @@ import type * as vscode from '@volar/language-service';
2
2
  import type * as ts from 'typescript';
3
3
  import type { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  import type { SharedContext } from '../semanticFeatures/types';
5
- export declare function convertDiagnostic(diag: ts.Diagnostic, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): vscode.Diagnostic | undefined;
6
- export declare function applyCompletionEntryDetails(ts: typeof import('typescript'), item: vscode.CompletionItem, data: ts.CompletionEntryDetails, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): void;
5
+ export declare function convertDiagnostic(diag: ts.Diagnostic, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.Diagnostic | undefined;
6
+ export declare function applyCompletionEntryDetails(ts: typeof import('typescript'), item: vscode.CompletionItem, data: ts.CompletionEntryDetails, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): void;
7
7
  export declare function convertCompletionInfo<T>(ts: typeof import('typescript'), completionContext: ts.CompletionInfo, document: TextDocument, position: vscode.Position, createData: (tsEntry: ts.CompletionEntry) => T): vscode.CompletionList;
8
8
  export declare function getLineText(document: TextDocument, line: number): string;
9
9
  export declare function convertNavigateToItem(item: ts.NavigateToItem, document: TextDocument): vscode.WorkspaceSymbol;
10
10
  export declare function convertInlayHint(hint: ts.InlayHint, document: TextDocument): vscode.InlayHint;
11
11
  export declare function convertHighlightSpan(span: ts.HighlightSpan, document: TextDocument): vscode.DocumentHighlight;
12
12
  export declare function convertSelectionRange(range: ts.SelectionRange, document: TextDocument): vscode.SelectionRange;
13
- export declare function convertFileTextChanges(changes: readonly ts.FileTextChanges[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): vscode.WorkspaceEdit;
14
- export declare function convertRenameLocations(newText: string, locations: readonly ts.RenameLocation[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): vscode.WorkspaceEdit;
15
- export declare function convertQuickInfo(ts: typeof import('typescript'), info: ts.QuickInfo, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): vscode.Hover;
13
+ export declare function convertFileTextChanges(changes: readonly ts.FileTextChanges[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.WorkspaceEdit;
14
+ export declare function convertRenameLocations(newText: string, locations: readonly ts.RenameLocation[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.WorkspaceEdit;
15
+ export declare function convertQuickInfo(ts: typeof import('typescript'), info: ts.QuickInfo, document: TextDocument, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): vscode.Hover;
16
16
  export declare function convertNavTree(item: ts.NavigationTree, document: TextDocument): vscode.DocumentSymbol[];
17
17
  export declare function convertOutliningSpan(outliningSpan: ts.OutliningSpan, document: TextDocument): vscode.FoldingRange;
18
18
  export declare function convertOutliningSpanKind(kind: ts.OutliningSpanKind): vscode.FoldingRangeKind | undefined;
19
- export declare function convertTextChange(edit: ts.TextChange, document: TextDocument): vscode.TextEdit;
19
+ export declare function convertTextChange(edit: ts.TextChange, document: TextDocument | undefined): vscode.TextEdit;
20
20
  export declare function convertCallHierarchyIncomingCall(item: ts.CallHierarchyIncomingCall, ctx: SharedContext): vscode.CallHierarchyIncomingCall;
21
21
  export declare function convertCallHierarchyOutgoingCall(item: ts.CallHierarchyOutgoingCall, fromDocument: TextDocument, ctx: SharedContext): vscode.CallHierarchyOutgoingCall;
22
22
  export declare function convertCallHierarchyItem(item: ts.CallHierarchyItem, ctx: SharedContext): vscode.CallHierarchyItem;
23
23
  export declare function convertDocumentSpanToLocation(documentSpan: ts.DocumentSpan, ctx: SharedContext): vscode.Location;
24
24
  export declare function convertDefinitionInfoAndBoundSpan(info: ts.DefinitionInfoAndBoundSpan, document: TextDocument, ctx: SharedContext): vscode.LocationLink[];
25
25
  export declare function convertDocumentSpantoLocationLink(documentSpan: ts.DocumentSpan, ctx: SharedContext): vscode.LocationLink;
26
- export declare function convertTextSpan(textSpan: ts.TextSpan, document: TextDocument): vscode.Range;
26
+ export declare function convertTextSpan(textSpan: ts.TextSpan, document: TextDocument | undefined): vscode.Range;
27
27
  //# sourceMappingURL=lspConverters.d.ts.map
@@ -509,17 +509,32 @@ function convertFileTextChanges(changes, fileNameToUri, getTextDocument) {
509
509
  workspaceEdit.documentChanges = [];
510
510
  }
511
511
  const uri = fileNameToUri(change.fileName);
512
- const doc = getTextDocument(uri);
513
512
  if (change.isNewFile) {
514
513
  workspaceEdit.documentChanges.push({ kind: 'create', uri });
514
+ workspaceEdit.documentChanges.push({
515
+ textDocument: {
516
+ uri,
517
+ version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
518
+ },
519
+ edits: change.textChanges.map(edit => ({
520
+ newText: edit.newText,
521
+ range: {
522
+ start: { line: 0, character: edit.span.start },
523
+ end: { line: 0, character: edit.span.start + edit.span.length },
524
+ },
525
+ })),
526
+ });
527
+ }
528
+ else {
529
+ const doc = getTextDocument(uri);
530
+ workspaceEdit.documentChanges.push({
531
+ textDocument: {
532
+ uri,
533
+ version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
534
+ },
535
+ edits: change.textChanges.map(edit => convertTextChange(edit, doc)),
536
+ });
515
537
  }
516
- workspaceEdit.documentChanges.push({
517
- textDocument: {
518
- uri,
519
- version: null, // fix https://github.com/johnsoncodehk/volar/issues/2025
520
- },
521
- edits: change.textChanges.map(edit => convertTextChange(edit, doc)),
522
- });
523
538
  }
524
539
  return workspaceEdit;
525
540
  }
@@ -781,6 +796,12 @@ function convertDocumentSpantoLocationLink(documentSpan, ctx) {
781
796
  }
782
797
  exports.convertDocumentSpantoLocationLink = convertDocumentSpantoLocationLink;
783
798
  function convertTextSpan(textSpan, document) {
799
+ if (!document) {
800
+ return {
801
+ start: { line: 0, character: 0 },
802
+ end: { line: 0, character: 0 },
803
+ };
804
+ }
784
805
  return {
785
806
  start: document.positionAt(textSpan.start),
786
807
  end: document.positionAt(textSpan.start + textSpan.length),
@@ -1,7 +1,7 @@
1
1
  import type * as ts from 'typescript';
2
2
  import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- export declare function plainWithLinks(parts: readonly ts.server.protocol.SymbolDisplayPart[] | string, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): string;
4
- export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): string;
5
- export declare function markdownDocumentation(documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): string;
6
- export declare function addMarkdownDocumentation(out: string, documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument): string;
3
+ export declare function plainWithLinks(parts: readonly ts.server.protocol.SymbolDisplayPart[] | string, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
4
+ export declare function tagsMarkdownPreview(tags: readonly ts.JSDocTagInfo[], fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
5
+ export declare function markdownDocumentation(documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
6
+ export declare function addMarkdownDocumentation(out: string, documentation: ts.server.protocol.SymbolDisplayPart[] | string | undefined, tags: ts.JSDocTagInfo[] | undefined, fileNameToUri: (fileName: string) => string, getTextDocument: (uri: string) => TextDocument | undefined): string;
7
7
  //# sourceMappingURL=previewer.d.ts.map
@@ -106,19 +106,34 @@ function convertLinkTags(parts, fileNameToUri, getTextDocument) {
106
106
  if (typeof currentLink.target === 'object' && 'fileName' in currentLink.target) {
107
107
  const _target = currentLink.target;
108
108
  const fileDoc = getTextDocument(fileNameToUri(_target.fileName));
109
- const start = fileDoc.positionAt(_target.textSpan.start);
110
- const end = fileDoc.positionAt(_target.textSpan.start + _target.textSpan.length);
111
- target = {
112
- file: _target.fileName,
113
- start: {
114
- line: start.line + 1,
115
- offset: start.character + 1,
116
- },
117
- end: {
118
- line: end.line + 1,
119
- offset: end.character + 1,
120
- },
121
- };
109
+ if (fileDoc) {
110
+ const start = fileDoc.positionAt(_target.textSpan.start);
111
+ const end = fileDoc.positionAt(_target.textSpan.start + _target.textSpan.length);
112
+ target = {
113
+ file: _target.fileName,
114
+ start: {
115
+ line: start.line + 1,
116
+ offset: start.character + 1,
117
+ },
118
+ end: {
119
+ line: end.line + 1,
120
+ offset: end.character + 1,
121
+ },
122
+ };
123
+ }
124
+ else {
125
+ target = {
126
+ file: _target.fileName,
127
+ start: {
128
+ line: 1,
129
+ offset: 1,
130
+ },
131
+ end: {
132
+ line: 1,
133
+ offset: 1,
134
+ },
135
+ };
136
+ }
122
137
  }
123
138
  if (target) {
124
139
  const link = fileNameToUri(target.file) + '#' + `L${target.start.line},${target.start.offset}`;
@@ -1,5 +1,5 @@
1
1
  import type * as ts from 'typescript';
2
2
  export declare namespace SymbolKind {
3
- function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 10 | 22 | 11 | 6 | 7 | 13 | 12 | 9 | 26 | 15;
3
+ function fromProtocolScriptElementKind(kind: ts.ScriptElementKind): 2 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 15 | 22 | 26;
4
4
  }
5
5
  //# sourceMappingURL=typeConverters.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-typescript",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "Integrate TypeScript into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/typescript",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -42,5 +42,5 @@
42
42
  "optional": true
43
43
  }
44
44
  },
45
- "gitHead": "391d2dc126cfb541c6b919d9acfa12eb0d6baa26"
45
+ "gitHead": "c4fa09f8f3858532e806d6b2ec9c65eecb66b1a1"
46
46
  }