11'use strict' ;
22
33import * as vscode from 'vscode' ;
4- import { LanguageClient , LanguageClientOptions , ServerOptions } from 'vscode-languageclient/node' ;
4+ import { LanguageClient , LanguageClientOptions , ServerOptions , TextDocumentFilter } from 'vscode-languageclient/node' ;
55import * as net from 'net' ;
66import * as child_process from 'child_process' ;
77import { existsSync } from 'fs' ;
@@ -212,7 +212,7 @@ function getTypeProfStream(
212212 } ) ;
213213}
214214
215- function invokeTypeProf ( folder : vscode . WorkspaceFolder ) : LanguageClient {
215+ function invokeTypeProf ( version : string , folder : vscode . WorkspaceFolder ) : LanguageClient {
216216 const reportError = ( msg : string ) => client ?. info ( msg ) ;
217217
218218 const serverOptions : ServerOptions = async ( ) => {
@@ -226,11 +226,19 @@ function invokeTypeProf(folder: vscode.WorkspaceFolder): LanguageClient {
226226 } ;
227227 } ;
228228
229+ const documentSelector : TextDocumentFilter [ ] = [
230+ { scheme : 'file' , language : 'ruby' } ,
231+ { scheme : 'file' , language : 'rbs' } ,
232+ ] ;
233+
234+ if ( compareVersions ( version , '0.30.1' ) < 0 ) {
235+ // I don't know why, but this prevents the notification of changes of RBS files.
236+ // This is needed because the old version of TypeProf does not support RBS changes.
237+ documentSelector [ 0 ] . pattern = '**/*.rb' ;
238+ }
239+
229240 const clientOptions : LanguageClientOptions = {
230- documentSelector : [
231- { scheme : 'file' , language : 'ruby' , pattern : '**/*.rb' } ,
232- { scheme : 'file' , language : 'rbs' } ,
233- ] ,
241+ documentSelector,
234242 outputChannel,
235243 synchronize : {
236244 fileEvents : vscode . workspace . createFileSystemWatcher ( '{**/*.rb,**/*.rbs}' ) ,
@@ -268,7 +276,7 @@ function startTypeProf(context: vscode.ExtensionContext, folder: vscode.Workspac
268276 return ;
269277 }
270278 showStatus ( `Starting Ruby TypeProf (${ version } )...` ) ;
271- client = invokeTypeProf ( folder ) ;
279+ client = invokeTypeProf ( version , folder ) ;
272280 await client . start ( ) ;
273281 showStatus ( 'Ruby TypeProf is running' ) ;
274282 if ( compareVersions ( version , '0.21.8' ) >= 0 ) {
0 commit comments