diff --git a/package.json b/package.json index 7f15e9b..ba88789 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "@sourcegraph/vscode-ws-jsonrpc": "^0.0.3-fork", "lodash": "^4.17.11", "rxjs": "^6.4.0", - "sourcegraph": "^22.0.0", + "sourcegraph": "^23.0.0", "type-zoo": "^3.2.1", "uuid": "^3.3.2", "vscode-languageserver-protocol": "^3.14.1", diff --git a/src/index.ts b/src/index.ts index f3f3613..7c7b941 100644 --- a/src/index.ts +++ b/src/index.ts @@ -118,7 +118,7 @@ export async function register({ textDocument: { uri: serverTextDocumentUri.href, languageId: textDocument.languageId, - text: textDocument.text, + text: textDocument.text || '', // TODO try to fetch contents from somewhere version: 1, }, } diff --git a/src/test/integration.test.ts b/src/test/integration.test.ts index b16a8cf..d6aa39b 100644 --- a/src/test/integration.test.ts +++ b/src/test/integration.test.ts @@ -25,7 +25,7 @@ const logger = new NoopLogger() describe('register()', () => { it('should initialize one connection with each workspace folder if the server is multi-root capable', async () => { const sourcegraph = createMockSourcegraphAPI() - sourcegraph.workspace.roots = [{ uri: 'git://repo1?rev' }, { uri: 'git://repo2?rev' }] + sourcegraph.workspace.roots = [{ uri: new URL('git://repo1?rev') }, { uri: new URL('git://repo2?rev') }] const server = { initialize: sinon.spy((params: InitializeParams): InitializeResult => ({ capabilities: {} })), } @@ -49,7 +49,7 @@ describe('register()', () => { }) it('should initialize one connection for each workspace folder if the server is not multi-root capable', async () => { const sourcegraph = createMockSourcegraphAPI() - sourcegraph.workspace.roots = [{ uri: 'git://repo1?rev' }, { uri: 'git://repo2?rev' }] + sourcegraph.workspace.roots = [{ uri: new URL('git://repo1?rev') }, { uri: new URL('git://repo2?rev') }] const server = { initialize: sinon.spy((params: InitializeParams): InitializeResult => ({ capabilities: {} })), } @@ -80,7 +80,7 @@ describe('register()', () => { }) it('should close a connection when a workspace folder is closed', async () => { const sourcegraph = createMockSourcegraphAPI() - sourcegraph.workspace.roots = [{ uri: 'git://repo1?rev' }, { uri: 'git://repo2?rev' }] + sourcegraph.workspace.roots = [{ uri: new URL('git://repo1?rev') }, { uri: new URL('git://repo2?rev') }] const server = { initialize: sinon.spy((params: InitializeParams): InitializeResult => ({ capabilities: {} })), } @@ -99,7 +99,7 @@ describe('register()', () => { sinon.assert.calledOnce(createConnection.returnValues[0].unsubscribe) }) it('should register a references provider if the server reports the references capability', async () => { - const repoRoot = 'https://sourcegraph.test/repo@rev/-/raw/' + const repoRoot = new URL('https://sourcegraph.test/repo@rev/-/raw/') const server = { initialize: sinon.spy( (params: InitializeParams): InitializeResult => ({ @@ -180,7 +180,7 @@ describe('register()', () => { ]) }) it('should register a definition provider if the server reports the definition capability', async () => { - const repoRoot = 'https://sourcegraph.test/repo@rev/-/raw/' + const repoRoot = new URL('https://sourcegraph.test/repo@rev/-/raw/') const server = { initialize: sinon.spy( (params: InitializeParams): InitializeResult => ({ @@ -257,7 +257,7 @@ describe('register()', () => { ]) }) it('should register a hover provider if the server reports the hover capability', async () => { - const repoRoot = 'https://sourcegraph.test/repo@rev/-/raw/' + const repoRoot = new URL('https://sourcegraph.test/repo@rev/-/raw/') const server = { initialize: sinon.spy( async (params: InitializeParams): Promise => ({ diff --git a/yarn.lock b/yarn.lock index cb5d628..6cbe7c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5233,10 +5233,10 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== -sourcegraph@^22.0.0: - version "22.0.0" - resolved "https://registry.npmjs.org/sourcegraph/-/sourcegraph-22.0.0.tgz#b259929c31bf367f5160056698a881dc26eb36bd" - integrity sha512-cJHby0OPCM0y0BmRTKhY89D02f9koROluHMJGQGNE8q9CoIVbe1s6ctHCytz7bjY9mKtCpQMbtxYQhfIm5S4lg== +sourcegraph@^23.0.0: + version "23.0.0" + resolved "https://registry.yarnpkg.com/sourcegraph/-/sourcegraph-23.0.0.tgz#1fb96015af3e84cc9cc2944823f04a7e952ed565" + integrity sha512-hQALHrTt+AK5ZAqUAUNhxO7ClSv/xyTjMQPBb+hQykKJrMaHTk+CnJNHs7dRfXYKnbnZeisQRjaxKGX8UecU0Q== spawn-error-forwarder@~1.0.0: version "1.0.0"