Skip to content

Commit d1574ed

Browse files
authored
Merge pull request #234 from mame/monitor-rbs
Monitor the changes of RBS files
2 parents 9534796 + 8a54ef1 commit d1574ed

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/extension.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
import * as vscode from 'vscode';
4-
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
4+
import { LanguageClient, LanguageClientOptions, ServerOptions, TextDocumentFilter } from 'vscode-languageclient/node';
55
import * as net from 'net';
66
import * as child_process from 'child_process';
77
import { 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

Comments
 (0)