Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: fix default size of inline peek diff #187072

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { Iterable } from 'vs/base/common/iterator';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Lazy } from 'vs/base/common/lazy';
import { Disposable, DisposableStore, IDisposable, IReference, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { clamp } from 'vs/base/common/numbers';
import { count } from 'vs/base/common/strings';
import { ThemeIcon } from 'vs/base/common/themables';
import { URI } from 'vs/base/common/uri';
Expand Down Expand Up @@ -520,8 +519,8 @@ export class TestingOutputPeekController extends Disposable implements IEditorCo
* Shows a peek for the message in the editor.
*/
public async show(uri: URI) {
const subjecet = this.retrieveTest(uri);
if (!subjecet) {
const subject = this.retrieveTest(uri);
if (!subject) {
return;
}

Expand All @@ -537,12 +536,12 @@ export class TestingOutputPeekController extends Disposable implements IEditorCo
this.peek.value!.create();
}

if (subjecet instanceof MessageSubject) {
const message = subjecet.messages[subjecet.messageIndex];
if (subject instanceof MessageSubject) {
const message = subject.messages[subject.messageIndex];
alert(renderStringAsPlaintext(message.message));
}

this.peek.value.setModel(subjecet);
this.peek.value.setModel(subject);
this.currentPeekUri = uri;
}

Expand Down Expand Up @@ -1022,7 +1021,7 @@ const diffEditorOptions: IDiffEditorConstructionOptions = {
diffAlgorithm: 'advanced',
};

const isDiffable = (message: ITestMessage): message is ITestErrorMessage & { actualOutput: string; expectedOutput: string } =>
const isDiffable = (message: ITestMessage): message is ITestErrorMessage & { actual: string; expected: string } =>
message.type === TestMessageType.Error && message.actual !== undefined && message.expected !== undefined;

class DiffContentProvider extends Disposable implements IPeekOutputRenderer {
Expand Down Expand Up @@ -1377,8 +1376,9 @@ const firstLine = (str: string) => {
};

const isMultiline = (str: string | undefined) => !!str && str.includes('\n');
const hintPeekStrHeight = (str: string | undefined) =>
clamp(str ? Math.max(count(str, '\n'), Math.ceil(str.length / 80)) + 3 : 0, 14, 24);

// add 5ish lines for the size of the title and decorations in the peek.
const hintPeekStrHeight = (str: string) => Math.min(count(str, '\n') + 5, 24);

class SimpleDiffEditorModel extends EditorModel {
public readonly original = this._original.object.textEditorModel;
Expand Down