Skip to content

Commit

Permalink
Merge branch 'main' into folding-range-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaeumer authored Sep 13, 2023
2 parents 956f3a8 + c880c61 commit c4439ef
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 82 deletions.
8 changes: 4 additions & 4 deletions client-node-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client-node-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@types/minimatch": "^3.0.5",
"@types/sinon": "^10.0.2",
"@types/uuid": "^8.3.1",
"@types/vscode": "1.79.0",
"@types/vscode": "1.82.0",
"find-process": "^1.4.7",
"glob": "^7.1.7",
"sinon": "^11.1.2",
Expand Down
8 changes: 4 additions & 4 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Microsoft Corporation",
"license": "MIT",
"engines": {
"vscode": "^1.79.0"
"vscode": "^1.82.0"
},
"repository": {
"type": "git",
Expand All @@ -24,7 +24,7 @@
"devDependencies": {
"@types/minimatch": "^3.0.5",
"@types/semver": "^7.3.10",
"@types/vscode": "1.79.0",
"@types/vscode": "1.82.0",
"shx": "^0.3.4"
},
"dependencies": {
Expand Down
5 changes: 4 additions & 1 deletion client/src/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1636,10 +1636,13 @@ export abstract class BaseLanguageClient implements FeatureClient<Middleware, La
private async handleConnectionError(error: Error, message: Message | undefined, count: number | undefined): Promise<void> {
const handlerResult: ErrorHandlerResult = await this._clientOptions.errorHandler!.error(error, message, count);
if (handlerResult.action === ErrorAction.Shutdown) {
this.error(handlerResult.message ?? `Client ${this._name}: connection to server is erroring. Shutting down server.`, undefined, handlerResult.handled === true ? false : 'force');
this.error(handlerResult.message ?? `Client ${this._name}: connection to server is erroring.\n${error.message}\nShutting down server.`, undefined, handlerResult.handled === true ? false : 'force');
this.stop().catch((error) => {
this.error(`Stopping server failed`, error, false);
});
} else {
this.error(handlerResult.message ??
`Client ${this._name}: connection to server is erroring.\n${error.message}`, undefined, handlerResult.handled === true ? false : 'force');
}
}

Expand Down
1 change: 0 additions & 1 deletion client/src/common/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
/// <reference path="../../typings/vscode.proposed.formatMultipleRanges.d.ts" />

import {
languages as Languages, Disposable, TextDocument, ProviderResult, Range as VRange, Position as VPosition, TextEdit as VTextEdit, FormattingOptions as VFormattingOptions,
Expand Down
2 changes: 1 addition & 1 deletion client/src/node/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import semverSatisfies = require('semver/functions/satisfies');
export * from 'vscode-languageserver-protocol/node';
export * from '../common/api';

const REQUIRED_VSCODE_VERSION = '^1.78.0'; // do not change format, updated by `updateVSCode` script
const REQUIRED_VSCODE_VERSION = '^1.82.0'; // do not change format, updated by `updateVSCode` script

export enum TransportKind {
stdio,
Expand Down
29 changes: 0 additions & 29 deletions client/typings/vscode.proposed.formatMultipleRanges.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion jsonrpc/src/common/messageBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export abstract class AbstractMessageBuffer implements RAL.MessageBuffer {
const header = headers[i];
const index: number = header.indexOf(':');
if (index === -1) {
throw new Error('Message header must separate key and value using :');
throw new Error(`Message header must separate key and value using ':'\n${header}`);
}
const key = header.substr(0, index);
const value = header.substr(index + 1).trim();
Expand Down
77 changes: 41 additions & 36 deletions jsonrpc/src/common/messageReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,46 +211,51 @@ export class ReadableStreamMessageReader extends AbstractMessageReader {
}

private onData(data: Uint8Array): void {
this.buffer.append(data);
while (true) {
if (this.nextMessageLength === -1) {
const headers = this.buffer.tryReadHeaders(true);
if (!headers) {
return;
}
const contentLength = headers.get('content-length');
if (!contentLength) {
this.fireError(new Error('Header must provide a Content-Length property.'));
return;
try {

this.buffer.append(data);
while (true) {
if (this.nextMessageLength === -1) {
const headers = this.buffer.tryReadHeaders(true);
if (!headers) {
return;
}
const contentLength = headers.get('content-length');
if (!contentLength) {
this.fireError(new Error(`Header must provide a Content-Length property.\n${JSON.stringify(Object.fromEntries(headers))}`));
return;
}
const length = parseInt(contentLength);
if (isNaN(length)) {
this.fireError(new Error(`Content-Length value must be a number. Got ${contentLength}`));
return;
}
this.nextMessageLength = length;
}
const length = parseInt(contentLength);
if (isNaN(length)) {
this.fireError(new Error('Content-Length value must be a number.'));
const body = this.buffer.tryReadBody(this.nextMessageLength);
if (body === undefined) {
/** We haven't received the full message yet. */
this.setPartialMessageTimer();
return;
}
this.nextMessageLength = length;
}
const body = this.buffer.tryReadBody(this.nextMessageLength);
if (body === undefined) {
/** We haven't received the full message yet. */
this.setPartialMessageTimer();
return;
this.clearPartialMessageTimer();
this.nextMessageLength = -1;
// Make sure that we convert one received message after the
// other. Otherwise it could happen that a decoding of a second
// smaller message finished before the decoding of a first larger
// message and then we would deliver the second message first.
this.readSemaphore.lock(async () => {
const bytes: Uint8Array = this.options.contentDecoder !== undefined
? await this.options.contentDecoder.decode(body)
: body;
const message = await this.options.contentTypeDecoder.decode(bytes, this.options);
this.callback(message);
}).catch((error) => {
this.fireError(error);
});
}
this.clearPartialMessageTimer();
this.nextMessageLength = -1;
// Make sure that we convert one received message after the
// other. Otherwise it could happen that a decoding of a second
// smaller message finished before the decoding of a first larger
// message and then we would deliver the second message first.
this.readSemaphore.lock(async () => {
const bytes: Uint8Array = this.options.contentDecoder !== undefined
? await this.options.contentDecoder.decode(body)
: body;
const message = await this.options.contentTypeDecoder.decode(bytes, this.options);
this.callback(message);
}).catch((error) => {
this.fireError(error);
});
} catch (error) {
this.fireError(error);
}
}

Expand Down
4 changes: 2 additions & 2 deletions jsonrpc/src/node/test/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ suite('Messages', () => {
assert.fail('Should not parse a message without a Content-Length');
});
reader.onError((err) => {
assert.strictEqual(err.message, 'Header must provide a Content-Length property.');
assert.strictEqual(err.message, 'Header must provide a Content-Length property.\n{"not-content-length":"43"}');
done();
});
readable.push('Not-Content-Length: 43\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"example"}');
Expand All @@ -343,7 +343,7 @@ suite('Messages', () => {
assert.fail('Should not parse a message without a Content-Length');
});
reader.onError((err) => {
assert.strictEqual(err.message, 'Content-Length value must be a number.');
assert.strictEqual(err.message, 'Content-Length value must be a number. Got NaN');
done();
});
readable.push('Content-Length: NaN\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"example"}');
Expand Down

0 comments on commit c4439ef

Please sign in to comment.