Skip to content

Commit 0ebd8c8

Browse files
authored
Merge branch 'microsoft:main' into main
2 parents 41c840e + b847d7d commit 0ebd8c8

File tree

52 files changed

+477
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+477
-146
lines changed

build/hygiene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function createGitIndexVinyls(paths) {
256256

257257
cp.exec(
258258
process.platform === 'win32' ? `git show :${relativePath}` : `git show ':${relativePath}'`,
259-
{ maxBuffer: 2000 * 1024, encoding: 'buffer' },
259+
{ maxBuffer: stat.size, encoding: 'buffer' },
260260
(err, out) => {
261261
if (err) {
262262
return e(err);

src/vs/platform/quickinput/browser/quickInput.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,10 @@ export class QuickPick<T extends IQuickPickItem> extends QuickInput implements I
831831
this.visibleDisposables.add((this._hideInput ? this.ui.list : this.ui.inputBox).onKeyDown((event: KeyboardEvent | StandardKeyboardEvent) => {
832832
switch (event.keyCode) {
833833
case KeyCode.DownArrow:
834-
if (isMacintosh ? event.metaKey : event.altKey) {
834+
// Don't support focusing next separator when quick navigate is enabled
835+
// ref: https://github.com/microsoft/vscode/issues/210461
836+
// TODO: Could we do this in a way that could play nice with quick navigate?
837+
if (this.quickNavigate === undefined && (isMacintosh ? event.metaKey : event.altKey)) {
835838
this.ui.list.focus(QuickInputListFocus.NextSeparator);
836839
} else {
837840
this.ui.list.focus(QuickInputListFocus.Next);
@@ -842,7 +845,8 @@ export class QuickPick<T extends IQuickPickItem> extends QuickInput implements I
842845
dom.EventHelper.stop(event, true);
843846
break;
844847
case KeyCode.UpArrow:
845-
if (isMacintosh ? event.metaKey : event.altKey) {
848+
// Don't support focusing next separator when quick navigate is enabled
849+
if (this.quickNavigate === undefined && (isMacintosh ? event.metaKey : event.altKey)) {
846850
this.ui.list.focus(QuickInputListFocus.PreviousSeparator);
847851
} else {
848852
this.ui.list.focus(QuickInputListFocus.Previous);

src/vs/platform/quickinput/browser/quickInputTree.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,20 @@ export class QuickInputTree extends Disposable {
744744
identityProvider: {
745745
getId: element => {
746746
// always prefer item over separator because if item is defined, it must be the main item type
747-
// always prefer a defined id if one was specified and use label as a fallback
748-
return element.item?.id
749-
?? element.item?.label
750-
?? element.separator?.id
751-
?? element.separator?.label
752-
?? '';
747+
const mainItem = element.item || element.separator;
748+
if (mainItem === undefined) {
749+
return '';
750+
}
751+
// always prefer a defined id if one was specified and use "label + description + detail" as a fallback
752+
if (mainItem.id !== undefined) {
753+
return mainItem.id;
754+
}
755+
let id = `label:${mainItem.label}`;
756+
id += `$$description:${mainItem.description}`;
757+
if (mainItem.type !== 'separator') {
758+
id += `$$detail:${mainItem.detail}`;
759+
}
760+
return id;
753761
},
754762
},
755763
alwaysConsumeMouseWheel: true

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

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

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

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

214214
export interface ICurrentPartialCommand {
215215
promptStartMarker?: IMarker;
216+
promptHeight?: number;
216217

217218
commandStartMarker?: IMarker;
218219
commandStartX?: number;
@@ -244,12 +245,23 @@ export interface ICurrentPartialCommand {
244245
*/
245246
isInvalid?: boolean;
246247

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+
247258
getPromptRowCount(): number;
248259
getCommandRowCount(): number;
249260
}
250261

251262
export class PartialTerminalCommand implements ICurrentPartialCommand {
252263
promptStartMarker?: IMarker;
264+
promptHeight?: number;
253265

254266
commandStartMarker?: IMarker;
255267
commandStartX?: number;

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

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ 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()));
157158
}
158159

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

211+
setPromptHeight(value: number) {
212+
this._currentCommand.promptHeight = value;
213+
}
214+
210215
setIsWindowsPty(value: boolean) {
211216
if (value && !(this._ptyHeuristics.value instanceof WindowsPtyHeuristics)) {
212217
const that = this;
@@ -280,6 +285,10 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
280285
return undefined;
281286
}
282287

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

511+
handleInput() { }
512+
502513
handleCommandStart(options?: IHandleCommandOptions) {
503514
this._hooks.commitCommandFinished();
504515

@@ -652,6 +663,28 @@ class WindowsPtyHeuristics extends Disposable {
652663
}
653664
}
654665

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+
655688
handleCommandStart() {
656689
this._capability.currentCommand.commandStartX = this._terminal.buffer.active.cursorX;
657690

@@ -713,21 +746,24 @@ class WindowsPtyHeuristics extends Disposable {
713746
if (prompt) {
714747
const adjustedPrompt = typeof prompt === 'string' ? prompt : prompt.prompt;
715748
this._capability.currentCommand.commandStartMarker = this._terminal.registerMarker(0)!;
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-
}
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));
727761
}
762+
728763
// use the regex to set the position as it's possible input has occurred
729764
this._capability.currentCommand.commandStartX = adjustedPrompt.length;
730765
this._logService.debug('CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted commandStart', `${start.line} -> ${this._capability.currentCommand.commandStartMarker.line}:${this._capability.currentCommand.commandStartX}`);
766+
this._capability.currentCommand.isAdjusted = true;
731767
this._flushPendingHandleCommandStartTask();
732768
return;
733769
}
@@ -1049,5 +1085,7 @@ function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number
10491085
}
10501086

10511087
function cloneMarker(xterm: Terminal, marker: IXtermMarker, offset: number = 0): IXtermMarker | undefined {
1052-
return xterm.registerMarker(marker.line - (xterm.buffer.active.baseY + xterm.buffer.active.cursorY) + offset);
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);
10531091
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ 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+
}
406410
}
407411
}
408412
case VSCodeOscPt.SetMark: {

src/vs/workbench/api/browser/mainThreadChatAgents2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export class MainThreadChatAgents2 extends Disposable implements MainThreadChatA
137137
name: dynamicProps.name,
138138
description: dynamicProps.description,
139139
extensionId: extension,
140+
extensionDisplayName: extensionDescription?.displayName ?? extension.value,
140141
extensionPublisher: extensionDescription?.publisherDisplayName ?? extension.value,
141142
metadata: revive(metadata),
142143
slashCommands: [],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,8 +1693,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
16931693
InteractiveSessionVoteDirection: extHostTypes.InteractiveSessionVoteDirection,
16941694
ChatCopyKind: extHostTypes.ChatCopyKind,
16951695
InteractiveEditorResponseFeedbackKind: extHostTypes.InteractiveEditorResponseFeedbackKind,
1696-
StackFrame: extHostTypes.StackFrame,
1697-
Thread: extHostTypes.Thread,
1696+
DebugStackFrame: extHostTypes.DebugStackFrame,
1697+
DebugThread: extHostTypes.DebugThread,
16981698
RelatedInformationType: extHostTypes.RelatedInformationType,
16991699
SpeechToTextStatus: extHostTypes.SpeechToTextStatus,
17001700
PartialAcceptTriggerKind: extHostTypes.PartialAcceptTriggerKind,

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { DebugSessionUUID, ExtHostDebugServiceShape, IBreakpointsDeltaDto, IThre
1515
import { IExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
1616
import { IExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
1717
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
18-
import { Breakpoint, DataBreakpoint, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, Location, Position, setBreakpointId, SourceBreakpoint, Thread, StackFrame, ThemeIcon } from 'vs/workbench/api/common/extHostTypes';
18+
import { Breakpoint, DataBreakpoint, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, Location, Position, setBreakpointId, SourceBreakpoint, DebugThread, DebugStackFrame, ThemeIcon } from 'vs/workbench/api/common/extHostTypes';
1919
import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
2020
import { AbstractDebugAdapter } from 'vs/workbench/contrib/debug/common/abstractDebugAdapter';
2121
import { MainThreadDebugVisualization, IAdapterDescriptor, IConfig, IDebugAdapter, IDebugAdapterExecutable, IDebugAdapterNamedPipeServer, IDebugAdapterServer, IDebugVisualization, IDebugVisualizationContext, IDebuggerContribution, DebugVisualizationType, IDebugVisualizationTreeItem } from 'vs/workbench/contrib/debug/common/debug';
@@ -44,8 +44,8 @@ export interface IExtHostDebugService extends ExtHostDebugServiceShape {
4444
onDidReceiveDebugSessionCustomEvent: Event<vscode.DebugSessionCustomEvent>;
4545
onDidChangeBreakpoints: Event<vscode.BreakpointsChangeEvent>;
4646
breakpoints: vscode.Breakpoint[];
47-
onDidChangeActiveStackItem: Event<vscode.Thread | vscode.StackFrame | undefined>;
48-
activeStackItem: vscode.Thread | vscode.StackFrame | undefined;
47+
onDidChangeActiveStackItem: Event<vscode.DebugThread | vscode.DebugStackFrame | undefined>;
48+
activeStackItem: vscode.DebugThread | vscode.DebugStackFrame | undefined;
4949

5050
addBreakpoints(breakpoints0: readonly vscode.Breakpoint[]): Promise<void>;
5151
removeBreakpoints(breakpoints0: readonly vscode.Breakpoint[]): Promise<void>;
@@ -97,8 +97,8 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
9797

9898
private readonly _onDidChangeBreakpoints: Emitter<vscode.BreakpointsChangeEvent>;
9999

100-
private _activeStackItem: vscode.Thread | vscode.StackFrame | undefined;
101-
private readonly _onDidChangeActiveStackItem: Emitter<vscode.Thread | vscode.StackFrame | undefined>;
100+
private _activeStackItem: vscode.DebugThread | vscode.DebugStackFrame | undefined;
101+
private readonly _onDidChangeActiveStackItem: Emitter<vscode.DebugThread | vscode.DebugStackFrame | undefined>;
102102

103103
private _debugAdapters: Map<number, IDebugAdapter>;
104104
private _debugAdaptersTrackers: Map<number, vscode.DebugAdapterTracker>;
@@ -144,7 +144,7 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
144144

145145
this._onDidChangeBreakpoints = new Emitter<vscode.BreakpointsChangeEvent>();
146146

147-
this._onDidChangeActiveStackItem = new Emitter<vscode.Thread | vscode.StackFrame | undefined>();
147+
this._onDidChangeActiveStackItem = new Emitter<vscode.DebugThread | vscode.DebugStackFrame | undefined>();
148148

149149
this._activeDebugConsole = new ExtHostDebugConsole(this._debugServiceProxy);
150150

@@ -278,11 +278,11 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
278278
// extension debug API
279279

280280

281-
get activeStackItem(): vscode.Thread | vscode.StackFrame | undefined {
281+
get activeStackItem(): vscode.DebugThread | vscode.DebugStackFrame | undefined {
282282
return this._activeStackItem;
283283
}
284284

285-
get onDidChangeActiveStackItem(): Event<vscode.Thread | vscode.StackFrame | undefined> {
285+
get onDidChangeActiveStackItem(): Event<vscode.DebugThread | vscode.DebugStackFrame | undefined> {
286286
return this._onDidChangeActiveStackItem.event;
287287
}
288288

@@ -769,13 +769,13 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
769769
}
770770

771771
public async $acceptStackFrameFocus(focusDto: IThreadFocusDto | IStackFrameFocusDto | undefined): Promise<void> {
772-
let focus: vscode.Thread | vscode.StackFrame | undefined;
772+
let focus: vscode.DebugThread | vscode.DebugStackFrame | undefined;
773773
if (focusDto) {
774774
const session = await this.getSession(focusDto.sessionId);
775775
if (focusDto.kind === 'thread') {
776-
focus = new Thread(session.api, focusDto.threadId);
776+
focus = new DebugThread(session.api, focusDto.threadId);
777777
} else {
778-
focus = new StackFrame(session.api, focusDto.threadId, focusDto.frameId);
778+
focus = new DebugStackFrame(session.api, focusDto.threadId, focusDto.frameId);
779779
}
780780
}
781781

0 commit comments

Comments
 (0)