@@ -8,7 +8,7 @@ import * as fs from 'fs';
88import * as nls from 'vscode-nls' ;
99const localize = nls . loadMessageBundle ( ) ;
1010
11- import { workspace , window , languages , commands , ExtensionContext , extensions , Uri , LanguageConfiguration , Diagnostic , StatusBarAlignment , TextEditor , TextDocument , Position , SelectionRange , Range , SelectionRangeKind } from 'vscode' ;
11+ import { workspace , window , languages , commands , ExtensionContext , extensions , Uri , LanguageConfiguration , Diagnostic , StatusBarAlignment , TextEditor , TextDocument , Position , SelectionRange } from 'vscode' ;
1212import { LanguageClient , LanguageClientOptions , RequestType , ServerOptions , TransportKind , NotificationType , DidChangeConfigurationNotification , HandleDiagnosticsSignature } from 'vscode-languageclient' ;
1313import TelemetryReporter from 'vscode-extension-telemetry' ;
1414
@@ -202,18 +202,18 @@ export function activate(context: ExtensionContext) {
202202 toDispose . push ( languages . registerSelectionRangeProvider ( selector , {
203203 async provideSelectionRanges ( document : TextDocument , positions : Position [ ] ) : Promise < SelectionRange [ ] [ ] > {
204204 const textDocument = client . code2ProtocolConverter . asTextDocumentIdentifier ( document ) ;
205- return Promise . all ( positions . map ( async position => {
206- const rawRanges = await client . sendRequest < Range [ ] > ( '$/textDocument/selectionRange' , { textDocument , position } ) ;
207- if ( Array . isArray ( rawRanges ) ) {
208- return rawRanges . map ( r => {
205+ const rawResult = await client . sendRequest < SelectionRange [ ] [ ] > ( '$/textDocument/selectionRanges' , { textDocument , positions : positions . map ( client . code2ProtocolConverter . asPosition ) } ) ;
206+ if ( Array . isArray ( rawResult ) ) {
207+ return rawResult . map ( rawSelectionRanges => {
208+ return rawSelectionRanges . map ( selectionRange => {
209209 return {
210- range : client . protocol2CodeConverter . asRange ( r ) ,
211- kind : SelectionRangeKind . Declaration
210+ range : client . protocol2CodeConverter . asRange ( selectionRange . range ) ,
211+ kind : selectionRange . kind
212212 } ;
213213 } ) ;
214- }
215- return [ ] ;
216- } ) ) ;
214+ } ) ;
215+ }
216+ return [ ] ;
217217 }
218218 } ) ) ;
219219 } ) ;
0 commit comments