Skip to content

Commit 835e71c

Browse files
authored
Merge branch 'microsoft:main' into main
2 parents 0ebd8c8 + 5ae5a74 commit 835e71c

File tree

17 files changed

+61
-89
lines changed

17 files changed

+61
-89
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ export interface ICommandDetectionCapability {
182182
readonly onCurrentCommandInvalidated: Event<ICommandInvalidationRequest>;
183183
setContinuationPrompt(value: string): void;
184184
setCwd(value: string): void;
185-
setPromptHeight(value: number): void;
186185
setIsWindowsPty(value: boolean): void;
187186
setIsCommandStorageDisabled(): void;
188187
/**

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ export class TerminalCommand implements ITerminalCommand {
213213

214214
export interface ICurrentPartialCommand {
215215
promptStartMarker?: IMarker;
216-
promptHeight?: number;
217216

218217
commandStartMarker?: IMarker;
219218
commandStartX?: number;
@@ -245,23 +244,12 @@ export interface ICurrentPartialCommand {
245244
*/
246245
isInvalid?: boolean;
247246

248-
/**
249-
* Whether the command start marker has been adjusted on Windows.
250-
*/
251-
isAdjusted?: boolean;
252-
253-
/**
254-
* Whether the command start marker adjustment has been attempt on new terminal input.
255-
*/
256-
isInputAdjusted?: boolean;
257-
258247
getPromptRowCount(): number;
259248
getCommandRowCount(): number;
260249
}
261250

262251
export class PartialTerminalCommand implements ICurrentPartialCommand {
263252
promptStartMarker?: IMarker;
264-
promptHeight?: number;
265253

266254
commandStartMarker?: IMarker;
267255
commandStartX?: number;

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

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
154154
};
155155
this._register(this._terminal.onResize(e => this._handleResize(e)));
156156
this._register(this._terminal.onCursorMove(() => this._handleCursorMove()));
157-
this._register(this._terminal.onData(() => this._handleInput()));
158157
}
159158

160159
private _handleResize(e: { cols: number; rows: number }) {
@@ -208,10 +207,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
208207
this._cwd = value;
209208
}
210209

211-
setPromptHeight(value: number) {
212-
this._currentCommand.promptHeight = value;
213-
}
214-
215210
setIsWindowsPty(value: boolean) {
216211
if (value && !(this._ptyHeuristics.value instanceof WindowsPtyHeuristics)) {
217212
const that = this;
@@ -285,10 +280,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
285280
return undefined;
286281
}
287282

288-
private _handleInput(): void {
289-
this._ptyHeuristics.value.handleInput();
290-
}
291-
292283
handlePromptStart(options?: IHandleCommandOptions): void {
293284
// Adjust the last command's finished marker when needed. The standard position for the
294285
// finished marker `D` to appear is at the same position as the following prompt started
@@ -508,8 +499,6 @@ class UnixPtyHeuristics extends Disposable {
508499
}));
509500
}
510501

511-
handleInput() { }
512-
513502
handleCommandStart(options?: IHandleCommandOptions) {
514503
this._hooks.commitCommandFinished();
515504

@@ -663,28 +652,6 @@ class WindowsPtyHeuristics extends Disposable {
663652
}
664653
}
665654

666-
/**
667-
* Attempt to adjust the command start marker when input is handled for the first time.
668-
*/
669-
handleInput() {
670-
const currentY = this._terminal.buffer.active.baseY + this._terminal.buffer.active.cursorY;
671-
672-
const hasWrappingInPrompt = Array.from({ length: (this._capability.currentCommand.promptHeight ?? 0) + 1 }, (_, i) => currentY - i).find(y => this._terminal.buffer.active.getLine(y)?.isWrapped) !== undefined;
673-
const hasActiveCommand = this._capability.currentCommand.commandStartX !== undefined && this._capability.currentCommand.commandExecutedX === undefined;
674-
const hasAdjusted = this._capability.currentCommand.isAdjusted === true || this._capability.currentCommand.isInputAdjusted === true;
675-
676-
if (!hasActiveCommand || hasAdjusted || hasWrappingInPrompt) {
677-
return;
678-
}
679-
this._capability.currentCommand.isInputAdjusted = true;
680-
this._logService.debug('CommandDetectionCapability#handleInput attempting start marker adjustment');
681-
682-
this._tryAdjustCommandStartMarkerScannedLineCount = 0;
683-
this._tryAdjustCommandStartMarkerPollCount = 0;
684-
this._tryAdjustCommandStartMarkerScheduler = new RunOnceScheduler(() => this._tryAdjustCommandStartMarker(this._terminal.registerMarker(0)!), AdjustCommandStartMarkerConstants.Interval);
685-
this._tryAdjustCommandStartMarkerScheduler.schedule();
686-
}
687-
688655
handleCommandStart() {
689656
this._capability.currentCommand.commandStartX = this._terminal.buffer.active.cursorX;
690657

@@ -746,24 +713,21 @@ class WindowsPtyHeuristics extends Disposable {
746713
if (prompt) {
747714
const adjustedPrompt = typeof prompt === 'string' ? prompt : prompt.prompt;
748715
this._capability.currentCommand.commandStartMarker = this._terminal.registerMarker(0)!;
749-
750-
// Adjust the prompt start marker to the command start marker
751-
this._logService.debug('CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted promptStart', `${this._capability.currentCommand.promptStartMarker?.line} -> ${this._capability.currentCommand.commandStartMarker.line}`);
752-
this._capability.currentCommand.promptStartMarker?.dispose();
753-
this._capability.currentCommand.promptStartMarker = cloneMarker(this._terminal, this._capability.currentCommand.commandStartMarker, -((this._capability.currentCommand.promptHeight ?? 1) - 1));
754-
755-
// Adjust the last command if it's not in the same position as the following
756-
// prompt start marker
757-
const lastCommand = this._capability.commands.at(-1);
758-
if (lastCommand && this._capability.currentCommand.commandStartMarker.line !== lastCommand.endMarker?.line) {
759-
lastCommand.endMarker?.dispose();
760-
lastCommand.endMarker = cloneMarker(this._terminal, this._capability.currentCommand.commandStartMarker, -((this._capability.currentCommand.promptHeight ?? 1) - 1));
716+
if (typeof prompt === 'object' && prompt.likelySingleLine) {
717+
this._logService.debug('CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted promptStart', `${this._capability.currentCommand.promptStartMarker?.line} -> ${this._capability.currentCommand.commandStartMarker.line}`);
718+
this._capability.currentCommand.promptStartMarker?.dispose();
719+
this._capability.currentCommand.promptStartMarker = cloneMarker(this._terminal, this._capability.currentCommand.commandStartMarker);
720+
// Adjust the last command if it's not in the same position as the following
721+
// prompt start marker
722+
const lastCommand = this._capability.commands.at(-1);
723+
if (lastCommand && this._capability.currentCommand.commandStartMarker.line !== lastCommand.endMarker?.line) {
724+
lastCommand.endMarker?.dispose();
725+
lastCommand.endMarker = cloneMarker(this._terminal, this._capability.currentCommand.commandStartMarker);
726+
}
761727
}
762-
763728
// use the regex to set the position as it's possible input has occurred
764729
this._capability.currentCommand.commandStartX = adjustedPrompt.length;
765730
this._logService.debug('CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted commandStart', `${start.line} -> ${this._capability.currentCommand.commandStartMarker.line}:${this._capability.currentCommand.commandStartX}`);
766-
this._capability.currentCommand.isAdjusted = true;
767731
this._flushPendingHandleCommandStartTask();
768732
return;
769733
}
@@ -1085,7 +1049,5 @@ function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number
10851049
}
10861050

10871051
function cloneMarker(xterm: Terminal, marker: IXtermMarker, offset: number = 0): IXtermMarker | undefined {
1088-
const cursorY = xterm.buffer.active.baseY + xterm.buffer.active.cursorY;
1089-
const cursorYOffset = marker.line - cursorY + offset;
1090-
return xterm.registerMarker((cursorY + cursorYOffset) < 0 ? -cursorY : cursorYOffset);
1052+
return xterm.registerMarker(marker.line - (xterm.buffer.active.baseY + xterm.buffer.active.cursorY) + offset);
10911053
}

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,6 @@ export class ShellIntegrationAddon extends Disposable implements IShellIntegrati
403403
this.capabilities.get(TerminalCapability.CommandDetection)?.setIsCommandStorageDisabled();
404404
return true;
405405
}
406-
case 'PromptHeight': {
407-
this.capabilities.get(TerminalCapability.CommandDetection)?.setPromptHeight(parseInt(value));
408-
return true;
409-
}
410406
}
411407
}
412408
case VSCodeOscPt.SetMark: {

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
16611661
LinkedEditingRanges: extHostTypes.LinkedEditingRanges,
16621662
TestResultState: extHostTypes.TestResultState,
16631663
TestRunRequest: extHostTypes.TestRunRequest,
1664+
TestRunRequest2: extHostTypes.TestRunRequest,
16641665
TestMessage: extHostTypes.TestMessage,
16651666
TestTag: extHostTypes.TestTag,
16661667
TestRunProfileKind: extHostTypes.TestRunProfileKind,

src/vs/workbench/api/common/extHostTesting.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class ExtHostTesting extends Disposable implements ExtHostTestingShape {
210210
}
211211

212212
await this.proxy.$runTests({
213-
isUiTriggered: false,
213+
preserveFocus: (req as vscode.TestRunRequest2).preserveFocus ?? true,
214214
targets: [{
215215
testIds: req.include?.map(t => TestId.fromExtHostTestItem(t, controller.collection.root.id).toString()) ?? [controller.collection.root.id],
216216
profileGroup: profileGroupToBitset[profile.kind],
@@ -746,6 +746,7 @@ export class TestRunCoordinator {
746746
exclude: request.exclude?.map(t => TestId.fromExtHostTestItem(t, collection.root.id).toString()) ?? [],
747747
id: dto.id,
748748
include: request.include?.map(t => TestId.fromExtHostTestItem(t, collection.root.id).toString()) ?? [collection.root.id],
749+
preserveFocus: (request as vscode.TestRunRequest2).preserveFocus ?? true,
749750
persist
750751
});
751752

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4018,12 +4018,13 @@ export enum TestRunProfileKind {
40184018
}
40194019

40204020
@es5ClassCompat
4021-
export class TestRunRequest implements vscode.TestRunRequest {
4021+
export class TestRunRequest implements vscode.TestRunRequest2 {
40224022
constructor(
40234023
public readonly include: vscode.TestItem[] | undefined = undefined,
40244024
public readonly exclude: vscode.TestItem[] | undefined = undefined,
40254025
public readonly profile: vscode.TestRunProfile | undefined = undefined,
40264026
public readonly continuous = false,
4027+
public readonly preserveFocus = true,
40274028
) { }
40284029
}
40294030

src/vs/workbench/api/test/browser/extHostTesting.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ suite('ExtHost Testing', () => {
752752
exclude: [new TestId(['ctrlId', 'id-b']).toString()],
753753
persist: false,
754754
continuous: false,
755+
preserveFocus: true,
755756
}]
756757
]);
757758

src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ class EntitlementsContribution extends Disposable implements IWorkbenchContribut
147147
}
148148
this.telemetryService.publicLog2<{ enabled: boolean }, EntitlementEnablementClassification>('entitlements.enabled', { enabled: true });
149149
this.isInitialized = true;
150-
const orgs = parsedResult['organization_login_list'] as any[];
151-
return [true, orgs ? orgs[orgs.length - 1] : undefined];
150+
const orgs: { login: string; name: string }[] = parsedResult['organization_list'] as { login: string; name: string }[];
151+
return [true, orgs && orgs.length > 0 ? (orgs[0].name ? orgs[0].name : orgs[0].login) : undefined];
152152
}
153153

154154
private async enableEntitlements(session: AuthenticationSession) {

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ __vsc_update_cwd() {
182182
builtin printf '\e]633;P;Cwd=%s\a' "$(__vsc_escape_value "$__vsc_cwd")"
183183
}
184184

185-
__vsc_update_prompt_height() {
186-
__vsc_prompt_height="$(("$(builtin printf "%s" "${PS1@P}" | wc -l)" + 1))"
187-
builtin printf '\e]633;P;PromptHeight=%s\a' "$(__vsc_escape_value "$__vsc_prompt_height")"
188-
}
189-
190185
__vsc_command_output_start() {
191186
builtin printf '\e]633;E;%s;%s\a' "$(__vsc_escape_value "${__vsc_current_command}")" $__vsc_nonce
192187
builtin printf '\e]633;C\a'
@@ -234,7 +229,6 @@ __vsc_precmd() {
234229
__vsc_command_complete "$__vsc_status"
235230
__vsc_current_command=""
236231
__vsc_update_prompt
237-
__vsc_update_prompt_height
238232
__vsc_first_prompt=1
239233
}
240234

0 commit comments

Comments
 (0)