Skip to content

Commit

Permalink
Merge pull request #28197 from cleidigh/debug-copy-all/cmd
Browse files Browse the repository at this point in the history
Add Debug Output Copy All command : Fixes #27079
  • Loading branch information
isidorn authored Jun 12, 2017
2 parents a65a1ba + 2bdc580 commit 0ace0d0
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/vs/workbench/parts/debug/electron-browser/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { IListService } from 'vs/platform/list/browser/listService';
import { attachListStyler } from 'vs/platform/theme/common/styler';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { clipboard } from 'electron';

const $ = dom.$;

Expand All @@ -59,6 +60,7 @@ export interface IPrivateReplService {
_serviceBrand: any;
navigateHistory(previous: boolean): void;
acceptReplInput(): void;
copyAllReplOutput(): void;
}

export class Repl extends Panel implements IPrivateReplService {
Expand Down Expand Up @@ -230,6 +232,19 @@ export class Repl extends Panel implements IPrivateReplService {
this.layout(this.dimension);
}

public copyAllReplOutput(): void {
let text = '';
const navigator = this.tree.getNavigator();
// skip first navigator element - the root node
while (navigator.next()) {
if (text) {
text += `\n`;
}
text += navigator.current().toString();
}
clipboard.writeText(text);
}

public layout(dimension: Dimension): void {
this.dimension = dimension;
if (this.tree) {
Expand Down Expand Up @@ -378,3 +393,20 @@ CommonEditorRegistry.registerEditorCommand(new SuggestCommand({
primary: KeyCode.RightArrow
}
}));

@editorAction
export class ReplCopyAllAction extends EditorAction {

constructor() {
super({
id: 'repl.action.copyall',
label: nls.localize('actions.repl.copyall', "Debug: Console Copy All"),
alias: 'Debug Console Copy All',
precondition: debug.CONTEXT_IN_DEBUG_REPL,
});
}

public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): void | TPromise<void> {
accessor.get(IPrivateReplService).copyAllReplOutput();
}
}

0 comments on commit 0ace0d0

Please sign in to comment.