Skip to content

Commit

Permalink
fix: copy logs text on Linux & Windows. Fixes #557 (#558)
Browse files Browse the repository at this point in the history
fix: copy logs text on windows

Co-authored-by: Anton Gilgur <[email protected]>
Signed-off-by: Adrien Delannoy <[email protected]>
  • Loading branch information
Adrien-D and agilgur5 authored Jun 6, 2024
1 parent af33af0 commit 0bce165
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/logs-viewer/logs-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class LogsViewer extends React.Component<LogsViewerProps> {
this.terminal.loadAddon(this.fitAddon);
this.terminal.open(container);
this.fitAddon.fit();
// handle Ctrl+C for copying logs
this.terminal.attachCustomKeyEventHandler((ev) => {
if (ev.ctrlKey && ev.code === "KeyC" && ev.type === "keydown") {
const selection = this.terminal.getSelection();
if (!selection) return true;

navigator.clipboard?.writeText(selection);
return false
}
});
}

public componentDidMount() {
Expand Down

0 comments on commit 0bce165

Please sign in to comment.