Skip to content

Commit

Permalink
testing: improve experience for test-correlated console output (micro…
Browse files Browse the repository at this point in the history
…soft#189993)

Previously, console messages associated with a test were shown in the
Test Results tree view, and clicking them opened a simple text editor
stripped of ANSI codes

![](https://memes.peet.io/img/23-08-ca47357c-e9e6-49fb-bb60-80a65e49af6e.png)

This was not a great experience, and caused some problems.

Instead, we now have a "Show Output" message for each test with output
in a tree view, which opens terminal output from _just_ that test case.

![](https://memes.peet.io/img/23-08-c3e00702-4f56-4974-9a98-cedcdf26179f.png)

> Input: would selecting the test's range from the entire output be a better experience?

Like the full results terminal, this will stream in data as the test runs.
Additionally, clicking inline test messages now opens a real terminal
with that message selected.

![](https://memes.peet.io/img/23-08-dc4e3b0d-d85c-44ce-abe0-168ce11e8220.png)

cc @Tyriar regarding the new method in IXtermTerminal

Closes microsoft#187104 (supplanting the pain point with better ux)

Found a couple quirks with the DiffEditorWidget2 that I didn't catch
in the initial `@deprecated`-triggered migration in debt week
(microsoft#189992, microsoft#189975), please bear in mind during testing
that these are separate issues.
  • Loading branch information
connor4312 authored Aug 9, 2023
1 parent 4ff3738 commit bf9c810
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
this._ensureCapabilitiesOrAddFailureTelemetry();
}

getMarkerId(terminal: Terminal, vscodeMarkerId: string) {
this._createOrGetBufferMarkDetection(terminal).getMark(vscodeMarkerId);
}

private _handleFinalTermSequence(data: string): boolean {
const didHandle = this._doHandleFinalTermSequence(data);
if (this._status === ShellIntegrationStatus.Off) {
Expand Down
16 changes: 15 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,17 @@ export interface IXtermTerminal extends IDisposable {
*/
selectAll(): void;

/**
* Selects the content between the two markers by their VS Code OSC `SetMarker`
* ID. It's a no-op if either of the two markers are not found.
*
* @param fromMarkerId Start marker ID
* @param toMarkerId End marker ID
* @param scrollIntoView Whether the terminal should scroll to the start of
* the range, defaults tof alse
*/
selectMarkedRange(fromMarkerId: string, toMarkerId: string, scrollIntoView?: boolean): void;

/**
* Copies the terminal selection.
* @param {boolean} copyAsHtml Whether to copy selection as HTML, defaults to false.
Expand Down Expand Up @@ -1096,8 +1107,11 @@ export interface IDetachedXtermTerminal extends IXtermTerminal {

/**
* Writes data to the terminal.
* @param data data to write
* @param callback Optional callback that fires when the data was processed
* by the parser.
*/
write(data: string | Uint8Array): void;
write(data: string | Uint8Array, callback?: () => void): void;

/**
* Resizes the terminal.
Expand Down
22 changes: 20 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
this._anyFocusedTerminalHasSelection.set(isFocused && this.raw.hasSelection());
}

write(data: string | Uint8Array): void {
this.raw.write(data);
write(data: string | Uint8Array, callback?: () => void): void {
this.raw.write(data, callback);
}

resize(columns: number, rows: number): void {
Expand Down Expand Up @@ -595,6 +595,24 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, ID
this.raw.clearSelection();
}

selectMarkedRange(fromMarkerId: string, toMarkerId: string, scrollIntoView = false) {
const detectionCapability = this.shellIntegration.capabilities.get(TerminalCapability.BufferMarkDetection);
if (!detectionCapability) {
return;
}

const start = detectionCapability.getMark(fromMarkerId);
const end = detectionCapability.getMark(toMarkerId);
if (start === undefined || end === undefined) {
return;
}

this.raw.selectLines(start.line, end.line);
if (scrollIntoView) {
this.raw.scrollToLine(start.line);
}
}

selectAll(): void {
this.raw.focus();
this.raw.selectAll();
Expand Down
Loading

0 comments on commit bf9c810

Please sign in to comment.