mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-11 10:38:31 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -543,10 +543,16 @@ class MessageBuffer {
|
||||
const el = arr[i];
|
||||
const elType = arrType[i];
|
||||
size += 1; // arg type
|
||||
if (elType === ArgType.String) {
|
||||
size += this.sizeLongString(el);
|
||||
} else {
|
||||
size += this.sizeVSBuffer(el);
|
||||
switch (elType) {
|
||||
case ArgType.String:
|
||||
size += this.sizeLongString(el);
|
||||
break;
|
||||
case ArgType.VSBuffer:
|
||||
size += this.sizeVSBuffer(el);
|
||||
break;
|
||||
case ArgType.Undefined:
|
||||
// empty...
|
||||
break;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
@@ -557,19 +563,25 @@ class MessageBuffer {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
const el = arr[i];
|
||||
const elType = arrType[i];
|
||||
if (elType === ArgType.String) {
|
||||
this.writeUInt8(ArgType.String);
|
||||
this.writeLongString(el);
|
||||
} else {
|
||||
this.writeUInt8(ArgType.VSBuffer);
|
||||
this.writeVSBuffer(el);
|
||||
switch (elType) {
|
||||
case ArgType.String:
|
||||
this.writeUInt8(ArgType.String);
|
||||
this.writeLongString(el);
|
||||
break;
|
||||
case ArgType.VSBuffer:
|
||||
this.writeUInt8(ArgType.VSBuffer);
|
||||
this.writeVSBuffer(el);
|
||||
break;
|
||||
case ArgType.Undefined:
|
||||
this.writeUInt8(ArgType.Undefined);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public readMixedArray(): Array<string | VSBuffer> {
|
||||
public readMixedArray(): Array<string | VSBuffer | undefined> {
|
||||
const arrLen = this._buff.readUInt8(this._offset); this._offset += 1;
|
||||
let arr: Array<string | VSBuffer> = new Array(arrLen);
|
||||
let arr: Array<string | VSBuffer | undefined> = new Array(arrLen);
|
||||
for (let i = 0; i < arrLen; i++) {
|
||||
const argType = <ArgType>this.readUInt8();
|
||||
switch (argType) {
|
||||
@@ -579,6 +591,9 @@ class MessageBuffer {
|
||||
case ArgType.VSBuffer:
|
||||
arr[i] = this.readVSBuffer();
|
||||
break;
|
||||
case ArgType.Undefined:
|
||||
arr[i] = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
@@ -587,12 +602,20 @@ class MessageBuffer {
|
||||
|
||||
class MessageIO {
|
||||
|
||||
private static _arrayContainsBuffer(arr: any[]): boolean {
|
||||
return arr.some(value => value instanceof VSBuffer);
|
||||
private static _arrayContainsBufferOrUndefined(arr: any[]): boolean {
|
||||
for (let i = 0, len = arr.length; i < len; i++) {
|
||||
if (arr[i] instanceof VSBuffer) {
|
||||
return true;
|
||||
}
|
||||
if (typeof arr[i] === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static serializeRequest(req: number, rpcId: number, method: string, args: any[], usesCancellationToken: boolean, replacer: JSONStringifyReplacer | null): VSBuffer {
|
||||
if (this._arrayContainsBuffer(args)) {
|
||||
if (this._arrayContainsBufferOrUndefined(args)) {
|
||||
let massagedArgs: VSBuffer[] = [];
|
||||
let massagedArgsType: ArgType[] = [];
|
||||
for (let i = 0, len = args.length; i < len; i++) {
|
||||
@@ -600,6 +623,9 @@ class MessageIO {
|
||||
if (arg instanceof VSBuffer) {
|
||||
massagedArgs[i] = arg;
|
||||
massagedArgsType[i] = ArgType.VSBuffer;
|
||||
} else if (typeof arg === 'undefined') {
|
||||
massagedArgs[i] = VSBuffer.alloc(0);
|
||||
massagedArgsType[i] = ArgType.Undefined;
|
||||
} else {
|
||||
massagedArgs[i] = VSBuffer.fromString(safeStringify(arg, replacer));
|
||||
massagedArgsType[i] = ArgType.String;
|
||||
@@ -767,5 +793,6 @@ const enum MessageType {
|
||||
|
||||
const enum ArgType {
|
||||
String = 1,
|
||||
VSBuffer = 2
|
||||
VSBuffer = 2,
|
||||
Undefined = 3
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user