Skip to content

Commit f9631e7

Browse files
authored
Merge pull request microsoft#250306 from microsoft/tyriar/248589
Import type from xterm/headless
2 parents 84200a8 + 1092d26 commit f9631e7

File tree

5 files changed

+31
-60
lines changed

5 files changed

+31
-60
lines changed

src/vs/platform/terminal/common/capabilities/capabilities.ts

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,11 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Event } from '../../../../base/common/event.js';
7-
import { IDisposable } from '../../../../base/common/lifecycle.js';
87
import type { IPromptInputModel, ISerializedPromptInputModel } from './commandDetection/promptInputModel.js';
98
import { ICurrentPartialCommand } from './commandDetection/terminalCommand.js';
109
import { ITerminalOutputMatch, ITerminalOutputMatcher } from '../terminal.js';
1110
import { ReplayEntry } from '../terminalProcess.js';
12-
13-
interface IEvent<T, U = void> {
14-
(listener: (arg1: T, arg2: U) => any): IDisposable;
15-
}
16-
17-
export interface IMarker extends IDisposable {
18-
/**
19-
* A unique identifier for this marker.
20-
*/
21-
readonly id: number;
22-
23-
/**
24-
* Whether this marker is disposed.
25-
*/
26-
readonly isDisposed: boolean;
27-
28-
/**
29-
* The actual line index in the buffer at this point in time. This is set to
30-
* -1 if the marker has been disposed.
31-
*/
32-
readonly line: number;
33-
34-
/**
35-
* Event listener to get notified when the marker gets disposed. Automatic disposal
36-
* might happen for a marker, that got invalidated by scrolling out or removal of
37-
* a line from the buffer.
38-
*/
39-
onDispose: IEvent<void>;
40-
}
41-
11+
import type { IMarker } from '@xterm/headless';
4212

4313
/**
4414
* Primarily driven by the shell integration feature, a terminal capability is the mechanism for
@@ -283,8 +253,8 @@ export interface INaiveCwdDetectionCapability {
283253

284254
export interface IPartialCommandDetectionCapability {
285255
readonly type: TerminalCapability.PartialCommandDetection;
286-
readonly commands: readonly IXtermMarker[];
287-
readonly onCommandFinished: Event<IXtermMarker>;
256+
readonly commands: readonly IMarker[];
257+
readonly onCommandFinished: Event<IMarker>;
288258
}
289259

290260
interface IBaseTerminalCommand {
@@ -307,9 +277,9 @@ interface IBaseTerminalCommand {
307277
export interface ITerminalCommand extends IBaseTerminalCommand {
308278
// Optional non-serializable
309279
readonly promptStartMarker?: IMarker;
310-
readonly marker?: IXtermMarker;
311-
endMarker?: IXtermMarker;
312-
readonly executedMarker?: IXtermMarker;
280+
readonly marker?: IMarker;
281+
endMarker?: IMarker;
282+
readonly executedMarker?: IMarker;
313283
readonly aliases?: string[][];
314284
readonly wasReplayed?: boolean;
315285

@@ -332,15 +302,15 @@ export interface ISerializedTerminalCommand extends IBaseTerminalCommand {
332302
/**
333303
* A clone of the IMarker from xterm which cannot be imported from common
334304
*/
335-
export interface IXtermMarker {
336-
readonly id: number;
337-
readonly isDisposed: boolean;
338-
readonly line: number;
339-
dispose(): void;
340-
onDispose: {
341-
(listener: () => any): { dispose(): void };
342-
};
343-
}
305+
// export interface IMarker {
306+
// readonly id: number;
307+
// readonly isDisposed: boolean;
308+
// readonly line: number;
309+
// dispose(): void;
310+
// onDispose: {
311+
// (listener: () => any): { dispose(): void };
312+
// };
313+
// }
344314

345315
export interface IMarkProperties {
346316
hoverMessage?: string;

src/vs/platform/terminal/common/capabilities/commandDetection/terminalCommand.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IMarkProperties, IMarker, ISerializedTerminalCommand, ITerminalCommand, IXtermMarker } from '../capabilities.js';
6+
import { IMarkProperties, ISerializedTerminalCommand, ITerminalCommand } from '../capabilities.js';
77
import { ITerminalOutputMatcher, ITerminalOutputMatch } from '../../terminal.js';
8-
import type { IBuffer, IBufferLine, Terminal } from '@xterm/headless';
8+
import type { IBuffer, IBufferLine, IMarker, Terminal } from '@xterm/headless';
99

1010
export interface ITerminalCommandProperties {
1111
command: string;
1212
commandLineConfidence: 'low' | 'medium' | 'high';
1313
isTrusted: boolean;
1414
timestamp: number;
1515
duration: number;
16-
marker: IXtermMarker | undefined;
16+
marker: IMarker | undefined;
1717
cwd: string | undefined;
1818
exitCode: number | undefined;
1919
commandStartLineContent: string | undefined;
@@ -22,8 +22,8 @@ export interface ITerminalCommandProperties {
2222
startX: number | undefined;
2323

2424
promptStartMarker?: IMarker | undefined;
25-
endMarker?: IXtermMarker | undefined;
26-
executedMarker?: IXtermMarker | undefined;
25+
endMarker?: IMarker | undefined;
26+
executedMarker?: IMarker | undefined;
2727
aliases?: string[][] | undefined;
2828
wasReplayed?: boolean | undefined;
2929
}
@@ -38,7 +38,7 @@ export class TerminalCommand implements ITerminalCommand {
3838
get promptStartMarker() { return this._properties.promptStartMarker; }
3939
get marker() { return this._properties.marker; }
4040
get endMarker() { return this._properties.endMarker; }
41-
set endMarker(value: IXtermMarker | undefined) { this._properties.endMarker = value; }
41+
set endMarker(value: IMarker | undefined) { this._properties.endMarker = value; }
4242
get executedMarker() { return this._properties.executedMarker; }
4343
get aliases() { return this._properties.aliases; }
4444
get wasReplayed() { return this._properties.wasReplayed; }
@@ -361,9 +361,9 @@ export class PartialTerminalCommand implements ICurrentPartialCommand {
361361
function extractCommandLine(
362362
buffer: IBuffer,
363363
cols: number,
364-
commandStartMarker: IXtermMarker | undefined,
364+
commandStartMarker: IMarker | undefined,
365365
commandStartX: number | undefined,
366-
commandExecutedMarker: IXtermMarker | undefined,
366+
commandExecutedMarker: IMarker | undefined,
367367
commandExecutedX: number | undefined
368368
): string {
369369
if (!commandStartMarker || !commandExecutedMarker || commandStartX === undefined || commandExecutedX === undefined) {

src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { debounce } from '../../../../base/common/decorators.js';
88
import { Emitter } from '../../../../base/common/event.js';
99
import { Disposable, MandatoryMutableDisposable, MutableDisposable } from '../../../../base/common/lifecycle.js';
1010
import { ILogService } from '../../../log/common/log.js';
11-
import { CommandInvalidationReason, ICommandDetectionCapability, ICommandInvalidationRequest, IHandleCommandOptions, ISerializedCommandDetectionCapability, ISerializedTerminalCommand, ITerminalCommand, IXtermMarker, TerminalCapability } from './capabilities.js';
11+
import { CommandInvalidationReason, ICommandDetectionCapability, ICommandInvalidationRequest, IHandleCommandOptions, ISerializedCommandDetectionCapability, ISerializedTerminalCommand, ITerminalCommand, TerminalCapability } from './capabilities.js';
1212
import { ITerminalOutputMatcher } from '../terminal.js';
1313
import { ICurrentPartialCommand, PartialTerminalCommand, TerminalCommand } from './commandDetection/terminalCommand.js';
1414
import { PromptInputModel, type IPromptInputModel } from './commandDetection/promptInputModel.js';
@@ -1047,6 +1047,6 @@ function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number
10471047
return content;
10481048
}
10491049

1050-
function cloneMarker(xterm: Terminal, marker: IXtermMarker, offset: number = 0): IXtermMarker | undefined {
1050+
function cloneMarker(xterm: Terminal, marker: IMarker, offset: number = 0): IMarker | undefined {
10511051
return xterm.registerMarker(marker.line - (xterm.buffer.active.baseY + xterm.buffer.active.cursorY) + offset);
10521052
}

src/vs/workbench/contrib/tasks/browser/taskTerminalStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ITaskService, Task } from '../common/taskService.js';
1313
import { ITerminalInstance } from '../../terminal/browser/terminal.js';
1414
import { MarkerSeverity } from '../../../../platform/markers/common/markers.js';
1515
import { spinningLoading } from '../../../../platform/theme/common/iconRegistry.js';
16-
import { IMarker } from '../../../../platform/terminal/common/capabilities/capabilities.js';
16+
import type { IMarker } from '@xterm/xterm';
1717
import { AccessibilitySignal, IAccessibilitySignalService } from '../../../../platform/accessibilitySignal/browser/accessibilitySignalService.js';
1818
import { ITerminalStatus } from '../../terminal/common/terminal.js';
1919

src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkOpeners.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IWorkspaceContextService } from '../../../../../../platform/workspace/c
1717
import { CommandDetectionCapability } from '../../../../../../platform/terminal/common/capabilities/commandDetectionCapability.js';
1818
import { TerminalBuiltinLinkType } from '../../browser/links.js';
1919
import { TerminalLocalFileLinkOpener, TerminalLocalFolderInWorkspaceLinkOpener, TerminalSearchLinkOpener } from '../../browser/terminalLinkOpeners.js';
20-
import { TerminalCapability, IXtermMarker } from '../../../../../../platform/terminal/common/capabilities/capabilities.js';
20+
import { TerminalCapability } from '../../../../../../platform/terminal/common/capabilities/capabilities.js';
2121
import { TerminalCapabilityStore } from '../../../../../../platform/terminal/common/capabilities/terminalCapabilityStore.js';
2222
import { IEditorService } from '../../../../../services/editor/common/editorService.js';
2323
import { IWorkbenchEnvironmentService } from '../../../../../services/environment/common/environmentService.js';
@@ -29,6 +29,7 @@ import { ITerminalLogService } from '../../../../../../platform/terminal/common/
2929
import { importAMDNodeModule } from '../../../../../../amdX.js';
3030
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js';
3131
import { TerminalCommand } from '../../../../../../platform/terminal/common/capabilities/commandDetection/terminalCommand.js';
32+
import type { IMarker } from '@xterm/headless';
3233

3334
interface ITerminalLinkActivationResult {
3435
source: 'editor' | 'search';
@@ -148,7 +149,7 @@ suite('Workbench - TerminalLinkOpeners', () => {
148149
startX: undefined,
149150
marker: {
150151
line: 0
151-
} as Partial<IXtermMarker> as any,
152+
} as Partial<IMarker> as any,
152153
})]);
153154
fileService.setFiles([
154155
URI.from({ scheme: Schemas.file, path: '/initial/cwd/foo/bar.txt' }),
@@ -287,7 +288,7 @@ suite('Workbench - TerminalLinkOpeners', () => {
287288
startX: undefined,
288289
marker: {
289290
line: 0
290-
} as Partial<IXtermMarker> as any,
291+
} as Partial<IMarker> as any,
291292
exitCode: 0,
292293
commandStartLineContent: '',
293294
markProperties: {}
@@ -549,7 +550,7 @@ suite('Workbench - TerminalLinkOpeners', () => {
549550
duration: 0,
550551
marker: {
551552
line: 0
552-
} as Partial<IXtermMarker> as any,
553+
} as Partial<IMarker> as any,
553554
})]);
554555
await opener.open({
555556
text: 'file.txt',

0 commit comments

Comments
 (0)