mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
chat: fix multiple problem pills not being added, and use problem messages to label pills
Fixes https://github.com/microsoft/vscode-copilot/issues/13506
This commit is contained in:
@@ -11,7 +11,6 @@ import { Codicon } from '../../../../base/common/codicons.js';
|
||||
import { IDisposable } from '../../../../base/common/lifecycle.js';
|
||||
import { Mimes } from '../../../../base/common/mime.js';
|
||||
import { basename, joinPath } from '../../../../base/common/resources.js';
|
||||
import { Mutable } from '../../../../base/common/types.js';
|
||||
import { URI } from '../../../../base/common/uri.js';
|
||||
import { IRange } from '../../../../editor/common/core/range.js';
|
||||
import { SymbolKinds } from '../../../../editor/common/languages.js';
|
||||
@@ -375,19 +374,11 @@ export class ChatDragAndDrop extends Themable {
|
||||
|
||||
private resolveMarkerAttachContext(markers: MarkerTransferData[]): IDiagnosticVariableEntry[] {
|
||||
return markers.map((marker): IDiagnosticVariableEntry => {
|
||||
const filter: Mutable<IDiagnosticVariableEntryFilterData> = {};
|
||||
let filter: IDiagnosticVariableEntryFilterData;
|
||||
if (!('severity' in marker)) {
|
||||
filter.filterUri = URI.revive(marker.uri);
|
||||
filter.filterSeverity = MarkerSeverity.Warning;
|
||||
filter = { filterUri: URI.revive(marker.uri), filterSeverity: MarkerSeverity.Warning };
|
||||
} else {
|
||||
filter.filterUri = URI.revive(marker.resource);
|
||||
filter.filterSeverity = marker.severity;
|
||||
filter.filterRange = {
|
||||
startLineNumber: marker.startLineNumber,
|
||||
startColumn: marker.startColumn,
|
||||
endLineNumber: marker.endLineNumber,
|
||||
endColumn: marker.endColumn
|
||||
};
|
||||
filter = IDiagnosticVariableEntryFilterData.fromMarker(marker);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -673,7 +673,7 @@ export async function createMarkersQuickPick(accessor: ServicesAccessor, onBackg
|
||||
resource: marker.resource,
|
||||
label: marker.message,
|
||||
description: localize('markers.panel.at.ln.col.number', "[Ln {0}, Col {1}]", '' + marker.startLineNumber, '' + marker.startColumn),
|
||||
entry: { filterUri: marker.resource, filterRange: { startLineNumber: marker.startLineNumber, endLineNumber: marker.endLineNumber, startColumn: marker.startColumn, endColumn: marker.endColumn } }
|
||||
entry: IDiagnosticVariableEntryFilterData.fromMarker(marker),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { IRange } from '../../../../editor/common/core/range.js';
|
||||
import { Location, SymbolKind, TextEdit } from '../../../../editor/common/languages.js';
|
||||
import { localize } from '../../../../nls.js';
|
||||
import { ILogService } from '../../../../platform/log/common/log.js';
|
||||
import { MarkerSeverity } from '../../../../platform/markers/common/markers.js';
|
||||
import { IMarker, MarkerSeverity } from '../../../../platform/markers/common/markers.js';
|
||||
import { CellUri, ICellEditOperation } from '../../notebook/common/notebookCommon.js';
|
||||
import { ChatAgentLocation, IChatAgentCommand, IChatAgentData, IChatAgentResult, IChatAgentService, IChatWelcomeMessageContent, reviveSerializedAgent } from './chatAgents.js';
|
||||
import { ChatRequestTextPart, IParsedChatRequest, reviveParsedChatRequest } from './chatParserTypes.js';
|
||||
@@ -95,6 +95,8 @@ export interface IImageVariableEntry extends Omit<IBaseChatRequestVariableEntry,
|
||||
}
|
||||
|
||||
export interface IDiagnosticVariableEntryFilterData {
|
||||
readonly owner?: string;
|
||||
readonly problemMessage?: string;
|
||||
readonly filterUri?: URI;
|
||||
readonly filterSeverity?: MarkerSeverity;
|
||||
readonly filterRange?: IRange;
|
||||
@@ -103,6 +105,15 @@ export interface IDiagnosticVariableEntryFilterData {
|
||||
export namespace IDiagnosticVariableEntryFilterData {
|
||||
export const icon = Codicon.warning;
|
||||
|
||||
export function fromMarker(marker: IMarker): IDiagnosticVariableEntryFilterData {
|
||||
return {
|
||||
filterUri: marker.resource,
|
||||
owner: marker.owner,
|
||||
problemMessage: marker.message,
|
||||
filterRange: { startLineNumber: marker.startLineNumber, endLineNumber: marker.endLineNumber, startColumn: marker.startColumn, endColumn: marker.endColumn }
|
||||
};
|
||||
}
|
||||
|
||||
export function toEntry(data: IDiagnosticVariableEntryFilterData) {
|
||||
return {
|
||||
id: id(data),
|
||||
@@ -115,10 +126,27 @@ export namespace IDiagnosticVariableEntryFilterData {
|
||||
}
|
||||
|
||||
export function id(data: IDiagnosticVariableEntryFilterData) {
|
||||
return [data.filterUri, data.filterSeverity, data.filterRange?.startLineNumber].join(':');
|
||||
return [data.filterUri, data.owner, data.filterSeverity, data.filterRange?.startLineNumber].join(':');
|
||||
}
|
||||
|
||||
export function label(data: IDiagnosticVariableEntryFilterData) {
|
||||
const enum TrimThreshold {
|
||||
MaxChars = 30,
|
||||
MaxSpaceLookback = 10,
|
||||
}
|
||||
if (data.problemMessage) {
|
||||
if (data.problemMessage.length < TrimThreshold.MaxChars) {
|
||||
return data.problemMessage;
|
||||
}
|
||||
|
||||
// Trim the message, on a space if it would not lose too much
|
||||
// data (MaxSpaceLookback) or just blindly otherwise.
|
||||
const lastSpace = data.problemMessage.lastIndexOf(' ', TrimThreshold.MaxChars);
|
||||
if (lastSpace === -1 || lastSpace + TrimThreshold.MaxSpaceLookback < TrimThreshold.MaxChars) {
|
||||
return data.problemMessage.substring(0, TrimThreshold.MaxChars) + '…';
|
||||
}
|
||||
return data.problemMessage.substring(0, lastSpace) + '…';
|
||||
}
|
||||
let labelStr = localize('chat.attachment.problems.all', "All Problems");
|
||||
if (data.filterUri) {
|
||||
labelStr = localize('chat.attachment.problems.inFile', "Problems in {0}", basename(data.filterUri));
|
||||
|
||||
Reference in New Issue
Block a user