mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Fix #46707
This commit is contained in:
parent
0bd949c012
commit
1b032162a1
|
@ -9,8 +9,10 @@ export default {
|
|||
MARKERS_PANEL_ID: 'workbench.panel.markers',
|
||||
MARKER_COPY_ACTION_ID: 'problems.action.copy',
|
||||
MARKER_COPY_MESSAGE_ACTION_ID: 'problems.action.copyMessage',
|
||||
RELATED_INFORMATION_COPY_MESSAGE_ACTION_ID: 'problems.action.copyRelatedInformationMessage',
|
||||
MARKER_OPEN_SIDE_ACTION_ID: 'problems.action.openToSide',
|
||||
MARKER_SHOW_PANEL_ID: 'workbench.action.showErrorsWarnings',
|
||||
|
||||
MarkerFocusContextKey: new RawContextKey<boolean>('problemFocus', true)
|
||||
MarkerFocusContextKey: new RawContextKey<boolean>('problemFocus', true),
|
||||
RelatedInformationFocusContextKey: new RawContextKey<boolean>('relatedInformationFocus', true)
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/wor
|
|||
import { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { localize } from 'vs/nls';
|
||||
import { Marker } from 'vs/workbench/parts/markers/electron-browser/markersModel';
|
||||
import { Marker, RelatedInformation } from 'vs/workbench/parts/markers/electron-browser/markersModel';
|
||||
import { MarkersPanel } from 'vs/workbench/parts/markers/electron-browser/markersPanel';
|
||||
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
|
||||
|
@ -101,7 +101,7 @@ registerAction({
|
|||
});
|
||||
registerAction({
|
||||
id: Constants.MARKER_COPY_MESSAGE_ACTION_ID,
|
||||
title: localize('copyMarkerMessage', "Copy Message"),
|
||||
title: localize('copyMessage', "Copy Message"),
|
||||
handler(accessor) {
|
||||
copyMessage(accessor.get(IPanelService));
|
||||
},
|
||||
|
@ -111,6 +111,18 @@ registerAction({
|
|||
group: 'navigation'
|
||||
}
|
||||
});
|
||||
registerAction({
|
||||
id: Constants.RELATED_INFORMATION_COPY_MESSAGE_ACTION_ID,
|
||||
title: localize('copyMessage', "Copy Message"),
|
||||
handler(accessor) {
|
||||
copyRelatedInformationMessage(accessor.get(IPanelService));
|
||||
},
|
||||
menu: {
|
||||
menuId: MenuId.ProblemsPanelContext,
|
||||
when: Constants.RelatedInformationFocusContextKey,
|
||||
group: 'navigation'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function copyMarker(panelService: IPanelService) {
|
||||
|
@ -133,6 +145,16 @@ function copyMessage(panelService: IPanelService) {
|
|||
}
|
||||
}
|
||||
|
||||
function copyRelatedInformationMessage(panelService: IPanelService) {
|
||||
const activePanel = panelService.getActivePanel();
|
||||
if (activePanel instanceof MarkersPanel) {
|
||||
const element = (<MarkersPanel>activePanel).getFocusElement();
|
||||
if (element instanceof RelatedInformation) {
|
||||
clipboard.writeText(element.raw.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface IActionDescriptor {
|
||||
id: string;
|
||||
handler: ICommandHandler;
|
||||
|
|
|
@ -96,14 +96,11 @@ export class Marker extends NodeWithId {
|
|||
}
|
||||
|
||||
public toString(): string {
|
||||
return [
|
||||
`file: '${this.raw.resource}'`,
|
||||
`severity: '${MarkerSeverity.toString(this.raw.severity)}'`,
|
||||
`message: '${this.raw.message}'`,
|
||||
`at: '${this.raw.startLineNumber},${this.raw.startColumn}'`,
|
||||
`source: '${this.raw.source ? this.raw.source : ''}'`,
|
||||
`code: '${this.raw.code ? this.raw.code : ''}'`
|
||||
].join('\n');
|
||||
return JSON.stringify({
|
||||
...this.raw,
|
||||
resource: this.raw.resource.path,
|
||||
relatedInformation: this.resourceRelatedInformation.length ? this.resourceRelatedInformation.map(r => ({ ...r.raw, resource: r.raw.resource.path })) : void 0
|
||||
}, null, '\t');
|
||||
}
|
||||
|
||||
static compare(a: Marker, b: Marker): number {
|
||||
|
|
|
@ -205,9 +205,16 @@ export class MarkersPanel extends Panel {
|
|||
});
|
||||
|
||||
const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService);
|
||||
this._register(this.tree.onDidChangeFocus((e: { focus: any }) => markerFocusContextKey.set(e.focus instanceof Marker)));
|
||||
const relatedInformationFocusContextKey = Constants.RelatedInformationFocusContextKey.bindTo(this.tree.contextKeyService);
|
||||
this._register(this.tree.onDidChangeFocus((e: { focus: any }) => {
|
||||
markerFocusContextKey.set(e.focus instanceof Marker);
|
||||
relatedInformationFocusContextKey.set(e.focus instanceof RelatedInformation);
|
||||
}));
|
||||
const focusTracker = this._register(dom.trackFocus(this.tree.getHTMLElement()));
|
||||
this._register(focusTracker.onDidBlur(() => markerFocusContextKey.set(false)));
|
||||
this._register(focusTracker.onDidBlur(() => {
|
||||
markerFocusContextKey.set(false);
|
||||
relatedInformationFocusContextKey.set(false);
|
||||
}));
|
||||
|
||||
const markersNavigator = this._register(new TreeResourceNavigator(this.tree, { openOnFocus: true }));
|
||||
this._register(debounceEvent(markersNavigator.openResource, (last, event) => event, 75, true)(options => {
|
||||
|
|
Loading…
Reference in a new issue