Skip to content

Commit 57b98e6

Browse files
NuckleMrBurrBurr
andauthored
Add Ctrl+U shortcut (#1703)
Co-authored-by: FREDERICK <[email protected]>
1 parent 10e22ad commit 57b98e6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/views/Commands.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@keydown.ctrl.65.prevent="jumpToStart"
2020
@keydown.ctrl.75.prevent="removeAfterCursor"
2121
@keydown.ctrl.76.prevent="clearTerminal"
22+
@keydown.ctrl.85.prevent="deleteBeforeCursorAndJumpToStart"
2223
>
2324
<input v-model="autocompleteSuggestion" type="text" spellcheck="false" class="terminal__input terminal__input--autocomplete">
2425
</div>
@@ -341,18 +342,29 @@
341342
this.log = [];
342343
},
343344
jumpToStart() {
344-
this.$refs['terminal-input'].setSelectionRange(0, 0);
345+
const el = this.$refs['terminal-input'];
346+
347+
if (el.setSelectionRange) setTimeout(() => el.setSelectionRange(0, 0), 0);
345348
},
346349
removeAfterCursor() {
347350
const pos = this.$refs['terminal-input'].selectionStart;
348351
this.command = this.command.substr(0, pos);
349352
},
353+
removeBeforeCursor() {
354+
const pos = this.$refs['terminal-input'].selectionStart;
355+
const inputLength = this.$refs['terminal-input'].value.length;
356+
this.command = this.command.substr(pos, inputLength);
357+
},
350358
moveCursorToEnd() {
351359
const el = this.$refs['terminal-input'];
352360
const len = this.command.length;
353361
354362
if (el.setSelectionRange) setTimeout(() => el.setSelectionRange(len, len), 0);
355363
},
364+
deleteBeforeCursorAndJumpToStart() {
365+
this.removeBeforeCursor();
366+
this.jumpToStart();
367+
},
356368
parseCommandsHTML(commandsWikiRaw) {
357369
const virtualDOM = createVirtualDOM(commandsWikiRaw);
358370
const commandsTableHTML = virtualDOM.querySelector('.markdown-heading > h2').parentElement.nextElementSibling;

0 commit comments

Comments
 (0)