Skip to content

Commit

Permalink
feat(cc-logs): add ctrl+A keystroke for selecting all log lines
Browse files Browse the repository at this point in the history
Fixes #1008
  • Loading branch information
pdesoyres-cc committed Jun 20, 2024
1 parent 2c9c02b commit b993c9c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/cc-logs/cc-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ export class CcLogs extends LitElement {
this._setFollow(false);
}

_onSelectAll () {
this._logsCtrl.selectAll();
}

// endregion

// region Copy logic
Expand Down
9 changes: 9 additions & 0 deletions src/components/cc-logs/logs-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ export class LogsController {
this._host._onSelectionChanged();
}

selectAll () {
if (this._logsFiltered.length > 0) {
this._selection = new Set(this._logsFiltered);
this._selectionLast = this._logsFiltered[this._logsFiltered.length - 1];
this._host.requestUpdate();
this._host._onSelectionChanged();
}
}

/**
* @return {number} The length of the selection
*/
Expand Down
5 changes: 5 additions & 0 deletions src/components/cc-logs/logs-input-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export class LogsInputController {
const logIndex = Number(e.target.closest(`.log`).dataset.index);
this._host._onClickLog(logIndex, this._keyModifiers);
}
else if (e.key === 'a' && this._keyModifiers.ctrl) {
// we prevent default because we don't want the native keyboard click simulation to be fired
e.preventDefault();
this._host._onSelectAll();
}
}

onKeyUp (e) {
Expand Down

0 comments on commit b993c9c

Please sign in to comment.