mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +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',
|
MARKERS_PANEL_ID: 'workbench.panel.markers',
|
||||||
MARKER_COPY_ACTION_ID: 'problems.action.copy',
|
MARKER_COPY_ACTION_ID: 'problems.action.copy',
|
||||||
MARKER_COPY_MESSAGE_ACTION_ID: 'problems.action.copyMessage',
|
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_OPEN_SIDE_ACTION_ID: 'problems.action.openToSide',
|
||||||
MARKER_SHOW_PANEL_ID: 'workbench.action.showErrorsWarnings',
|
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 { KeybindingsRegistry, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||||
import { localize } from 'vs/nls';
|
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 { MarkersPanel } from 'vs/workbench/parts/markers/electron-browser/markersPanel';
|
||||||
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
import { MenuId, MenuRegistry, SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||||
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
|
import { PanelRegistry, Extensions as PanelExtensions, PanelDescriptor } from 'vs/workbench/browser/panel';
|
||||||
|
@ -101,7 +101,7 @@ registerAction({
|
||||||
});
|
});
|
||||||
registerAction({
|
registerAction({
|
||||||
id: Constants.MARKER_COPY_MESSAGE_ACTION_ID,
|
id: Constants.MARKER_COPY_MESSAGE_ACTION_ID,
|
||||||
title: localize('copyMarkerMessage', "Copy Message"),
|
title: localize('copyMessage', "Copy Message"),
|
||||||
handler(accessor) {
|
handler(accessor) {
|
||||||
copyMessage(accessor.get(IPanelService));
|
copyMessage(accessor.get(IPanelService));
|
||||||
},
|
},
|
||||||
|
@ -111,6 +111,18 @@ registerAction({
|
||||||
group: 'navigation'
|
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) {
|
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 {
|
interface IActionDescriptor {
|
||||||
id: string;
|
id: string;
|
||||||
handler: ICommandHandler;
|
handler: ICommandHandler;
|
||||||
|
|
|
@ -96,14 +96,11 @@ export class Marker extends NodeWithId {
|
||||||
}
|
}
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
return [
|
return JSON.stringify({
|
||||||
`file: '${this.raw.resource}'`,
|
...this.raw,
|
||||||
`severity: '${MarkerSeverity.toString(this.raw.severity)}'`,
|
resource: this.raw.resource.path,
|
||||||
`message: '${this.raw.message}'`,
|
relatedInformation: this.resourceRelatedInformation.length ? this.resourceRelatedInformation.map(r => ({ ...r.raw, resource: r.raw.resource.path })) : void 0
|
||||||
`at: '${this.raw.startLineNumber},${this.raw.startColumn}'`,
|
}, null, '\t');
|
||||||
`source: '${this.raw.source ? this.raw.source : ''}'`,
|
|
||||||
`code: '${this.raw.code ? this.raw.code : ''}'`
|
|
||||||
].join('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static compare(a: Marker, b: Marker): number {
|
static compare(a: Marker, b: Marker): number {
|
||||||
|
|
|
@ -205,9 +205,16 @@ export class MarkersPanel extends Panel {
|
||||||
});
|
});
|
||||||
|
|
||||||
const markerFocusContextKey = Constants.MarkerFocusContextKey.bindTo(this.tree.contextKeyService);
|
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()));
|
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 }));
|
const markersNavigator = this._register(new TreeResourceNavigator(this.tree, { openOnFocus: true }));
|
||||||
this._register(debounceEvent(markersNavigator.openResource, (last, event) => event, 75, true)(options => {
|
this._register(debounceEvent(markersNavigator.openResource, (last, event) => event, 75, true)(options => {
|
||||||
|
|
Loading…
Reference in a new issue