diff --git a/src/server/features/smartSelect.ts b/src/server/features/smartSelect.ts index 8de56bb..ab45ab2 100644 --- a/src/server/features/smartSelect.ts +++ b/src/server/features/smartSelect.ts @@ -5,11 +5,25 @@ import * as Proto from '../protocol' import { ITypeScriptServiceClient } from '../typescriptService' -import { TextDocument, Position, CancellationToken } from 'vscode-languageserver-protocol' -import { SelectionRange } from 'vscode-languageserver-protocol/lib/protocol.selectionRange.proposed' +import { TextDocument, Range, Position, CancellationToken } from 'vscode-languageserver-protocol' import * as typeConverters from '../utils/typeConverters' import { SelectionRangeProvider } from 'coc.nvim' +/** + * A selection range represents a part of a selection hierarchy. A selection range + * may have a parent selection range that contains it. + */ +export interface SelectionRange { + /** + * The [range](#Range) of this selection range. + */ + range: Range + /** + * The parent selection range containing this range. Therefore `parent.range` must contain `this.range`. + */ + parent?: SelectionRange +} + export default class SmartSelection implements SelectionRangeProvider { public constructor( private readonly client: ITypeScriptServiceClient @@ -39,9 +53,9 @@ export default class SmartSelection implements SelectionRangeProvider { private static convertSelectionRange( selectionRange: Proto.SelectionRange ): SelectionRange { - return SelectionRange.create( - typeConverters.Range.fromTextSpan(selectionRange.textSpan), - selectionRange.parent ? SmartSelection.convertSelectionRange(selectionRange.parent) : undefined, - ) + return { + range: typeConverters.Range.fromTextSpan(selectionRange.textSpan), + parent: selectionRange.parent ? SmartSelection.convertSelectionRange(selectionRange.parent) : undefined, + } } }