Merge from vscode 3d67364fbfcf676d93be64f949e9b33e7f1b969e (#5028)

This commit is contained in:
Anthony Dresser
2019-04-14 22:29:14 -07:00
committed by GitHub
parent 6dbf757385
commit 57242a2e13
210 changed files with 4898 additions and 3018 deletions

View File

@@ -250,7 +250,8 @@ export class DebugHoverWidget implements IContentWidget {
}
private layoutTreeAndContainer(): void {
const treeHeight = Math.min(MAX_TREE_HEIGHT, this.tree.contentHeight);
const scrollBarHeight = 8;
const treeHeight = Math.min(MAX_TREE_HEIGHT, this.tree.contentHeight + scrollBarHeight);
this.treeContainer.style.height = `${treeHeight}px`;
this.tree.layout(treeHeight, 324);
}

View File

@@ -720,11 +720,25 @@ class ReplDelegate implements IListVirtualDelegate<IReplElement> {
getHeight(element: IReplElement): number {
// Give approximate heights. Repl has dynamic height so the tree will measure the actual height on its own.
const fontSize = this.configurationService.getValue<IDebugConfiguration>('debug').console.fontSize;
const rowHeight = Math.ceil(1.4 * fontSize);
if (element instanceof Expression && element.hasChildren) {
return Math.ceil(2 * 1.4 * fontSize);
return 2 * rowHeight;
}
return Math.ceil(1.4 * fontSize);
// In order to keep scroll position we need to give a good approximation to the tree
if (element instanceof SimpleReplElement) {
// For every 150 characters increase the number of lines needed
let count = Math.ceil(element.value.length / 150);
for (let i = 0; i < element.value.length; i++) {
if (element.value[i] === '\n' || element.value[i] === '\r\n') {
count++;
}
}
return Math.max(1, count) * rowHeight;
}
return rowHeight;
}
getTemplateId(element: IReplElement): string {

View File

@@ -10,6 +10,7 @@ import { Expression, SimpleReplElement, RawObjectReplElement } from 'vs/workbenc
import { isUndefinedOrNull, isObject } from 'vs/base/common/types';
import { basenameOrAuthority } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { endsWith } from 'vs/base/common/strings';
const MAX_REPL_LENGTH = 10000;
let topReplElementCounter = 0;
@@ -39,8 +40,13 @@ export class ReplModel {
}
if (typeof data === 'string') {
const element = new SimpleReplElement(`topReplElement:${topReplElementCounter++}`, data.trimRight(), sev, source);
this.addReplElement(element);
const previousElement = this.replElements.length ? this.replElements[this.replElements.length - 1] : undefined;
if (previousElement instanceof SimpleReplElement && previousElement.severity === sev && !endsWith(previousElement.value, '\n') && !endsWith(previousElement.value, '\r\n')) {
previousElement.value += data;
} else {
const element = new SimpleReplElement(`topReplElement:${topReplElementCounter++}`, data, sev, source);
this.addReplElement(element);
}
} else {
// TODO@Isidor hack, we should introduce a new type which is an output that can fetch children like an expression
(<any>data).severity = sev;

View File

@@ -509,7 +509,7 @@ export class DebugService implements IDebugService {
// 'Run without debugging' mode VSCode must terminate the extension host. More details: #3905
if (isExtensionHostDebugging(session.configuration) && session.state === State.Running && session.configuration.noDebug) {
this.extensionHostDebugService.close(session.root.uri);
this.extensionHostDebugService.close(session.getId());
}
this.telemetryDebugSessionStop(session, adapterExitEvent);
@@ -556,8 +556,8 @@ export class DebugService implements IDebugService {
return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? session.restart() : undefined);
}
if (isExtensionHostDebugging(session.configuration) && session.root) {
return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? this.extensionHostDebugService.reload(session.root.uri) : undefined);
if (isExtensionHostDebugging(session.configuration)) {
return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? this.extensionHostDebugService.reload(session.getId()) : undefined);
}
const shouldFocus = this.viewModel.focusedSession && session.getId() === this.viewModel.focusedSession.getId();

View File

@@ -423,34 +423,41 @@ suite('Debug - Model', () => {
const session = new DebugSession({ resolved: { name: 'mockSession', type: 'node', request: 'launch' }, unresolved: undefined }, undefined!, model, undefined, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!, undefined!);
const repl = new ReplModel(session);
repl.appendToRepl('first line\n', severity.Error);
repl.appendToRepl('second line', severity.Error);
repl.appendToRepl('third line', severity.Warning);
repl.appendToRepl('second line ', severity.Error);
repl.appendToRepl('third line ', severity.Error);
repl.appendToRepl('fourth line', severity.Error);
let elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 4);
assert.equal(elements[0].value, 'first line');
assert.equal(elements.length, 2);
assert.equal(elements[0].value, 'first line\n');
assert.equal(elements[0].severity, severity.Error);
assert.equal(elements[1].value, 'second line');
assert.equal(elements[1].value, 'second line third line fourth line');
assert.equal(elements[1].severity, severity.Error);
assert.equal(elements[2].value, 'third line');
assert.equal(elements[2].severity, severity.Warning);
assert.equal(elements[3].value, 'fourth line');
assert.equal(elements[3].severity, severity.Error);
repl.appendToRepl('1', severity.Warning);
elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 5);
assert.equal(elements[4].value, '1');
assert.equal(elements[4].severity, severity.Warning);
assert.equal(elements.length, 3);
assert.equal(elements[2].value, '1');
assert.equal(elements[2].severity, severity.Warning);
const keyValueObject = { 'key1': 2, 'key2': 'value' };
repl.appendToRepl(new RawObjectReplElement('fakeid', 'fake', keyValueObject), severity.Info);
const element = <RawObjectReplElement>repl.getReplElements()[5];
const element = <RawObjectReplElement>repl.getReplElements()[3];
assert.equal(element.value, 'Object');
assert.deepEqual(element.valueObj, keyValueObject);
repl.removeReplExpressions();
assert.equal(repl.getReplElements().length, 0);
repl.appendToRepl('1\n', severity.Info);
repl.appendToRepl('2', severity.Info);
repl.appendToRepl('3\n4', severity.Info);
repl.appendToRepl('5\n', severity.Info);
repl.appendToRepl('6', severity.Info);
elements = <SimpleReplElement[]>repl.getReplElements();
assert.equal(elements.length, 3);
assert.equal(elements[0], '1\n');
assert.equal(elements[1], '23\n45\n');
assert.equal(elements[2], '6');
});
});