-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Copy all' for context menu in output view #8057
'Copy all' for context menu in output view #8057
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@salkin-naj we have a clipboard-service
which should be used instead and has handling for specific cases:
theia/packages/core/src/browser/clipboard-service.ts
Lines 20 to 23 in d017cb2
export interface ClipboardService { | |
readText(): MaybePromise<string>; | |
writeText(value: string): MaybePromise<void>; | |
} |
@vince-fugnitto: I tried using the |
@salkin-naj you can push your changes so far and I can take a look at it with you to help you along the way if you'd like :) import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
export class OutputContribution extends AbstractViewContribution<OutputWidget> implements OpenHandler {
@inject(ClipboardService)
protected readonly clipboardService: ClipboardService;
...
this.clipboardService.writeText('foo');
} |
98c5f20
to
6e7386d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes work well with the service, I have some comments about some improvements.
@@ -100,11 +101,19 @@ export namespace OutputCommands { | |||
category: OUTPUT_CATEGORY | |||
}; | |||
|
|||
export const COPY_ALL: Command = { | |||
id: 'output:copy-all', | |||
label: 'Copy all', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Copy All
registerKeybindings(registry: KeybindingRegistry): void { | ||
registry.registerKeybinding({ | ||
command: OutputCommands.COPY_ALL.id, | ||
keybinding: 'ctrlcmd+shift+c' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@salkin-naj we should only register the keybinding when the view has focus else it will override all other commands with ctrlc+shift+c which is not the behavior we would want or expect.
We can do so by implementing a when
context similarly to how it is done in other views:
Please let me know if you require help, I could assist you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everybody can do Ctrl/⌘+A then Ctrl/⌘+C. We do not need a keybinding for this. Please remove.
6e7386d
to
3342e53
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great, @salkin-naj. Let's simplify a little bit and were are ready to go ;)
Thank you! 🙏
return model.getValue(); | ||
} | ||
} | ||
return ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's return undefined
when the model value cannot be retrieved.
getText(): string | undefined {
const editor = this.editor;
if (editor) {
const model = editor.getControl().getModel();
if (model) {
return model.getValue();
}
}
return undefined;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution, @salkin-naj 🥇
Please make sure you have squashed and the commit is signed. |
8285f46
to
dbf7cb4
Compare
@kittaakos Done :) |
dbf7cb4
to
e196e15
Compare
@salkin-naj, I found a bug. I cannot accept the PR as is 😕 I propose the following: diff --git a/packages/output/src/browser/output-contribution.ts b/packages/output/src/browser/output-contribution.ts
index daf4a4903..b16646b75 100644
--- a/packages/output/src/browser/output-contribution.ts
+++ b/packages/output/src/browser/output-contribution.ts
@@ -102,9 +102,7 @@ export namespace OutputCommands {
};
export const COPY_ALL: Command = {
- id: 'output:copy-all',
- label: 'Copy All',
- category: OUTPUT_CATEGORY,
+ id: 'output:copy-all'
};
}
@@ -161,7 +159,8 @@ export class OutputContribution extends AbstractViewContribution<OutputWidget> i
commandId: CommonCommands.COPY.id
});
registry.registerMenuAction(OutputContextMenu.TEXT_EDIT_GROUP, {
- commandId: OutputCommands.COPY_ALL.id
+ commandId: OutputCommands.COPY_ALL.id,
+ label: 'Copy All'
});
registry.registerMenuAction(OutputContextMenu.COMMAND_GROUP, {
commandId: quickCommand.id, If you add a 👆Solution: move the |
This adds another option to the context menu of the output view, which copies everything in the selected channel into the clipboard, using the ClipboardService. Closes eclipse-theia#7912 Signed-off-by: Jan-Niklas Spangenberg <jan-niklas.spangenberg@gmx.de>
e196e15
to
2cbc217
Compare
Thanks for your persistence on this PR, @salkin-naj |
What it does
This adds another option to the context menu of the output view.
It copies everything in the selected channel into the clipboard.
How to test
Review checklist
Reminder for reviewers