@@ -952,7 +952,6 @@ const _printHelp = (regExp: RegExp, srcStr: string) => {
952
952
}
953
953
954
954
const _inputEnter = (e : KeyboardEvent ) => {
955
- e .preventDefault ()
956
955
if (e .ctrlKey ) {
957
956
if (command .value .length > 0 ) {
958
957
let cursorIdx = cursorConf .idx
@@ -967,18 +966,6 @@ const _inputEnter = (e: KeyboardEvent) => {
967
966
})
968
967
}
969
968
} else {
970
- // 因无法阻止回车输入,这里手动删掉前后一个回车
971
- let cursorIdx = terminalCmdInputRef .value .selectionStart
972
- let enterIdx = - 1
973
- if (command .value [cursorIdx ] == ' \n ' ) {
974
- enterIdx = cursorIdx
975
- } else if (command .value [cursorIdx - 1 ] == ' \n ' ) {
976
- enterIdx = cursorIdx - 1
977
- }
978
-
979
- if (enterIdx >= 0 ) {
980
- command .value = command .value .substring (0 , enterIdx ) + command .value .substring (enterIdx + 1 )
981
- }
982
969
_execute ()
983
970
}
984
971
}
@@ -1290,7 +1277,6 @@ const _calculateCursorPos = (cmdStr?: string) => {
1290
1277
_calculateByteLen ()
1291
1278
1292
1279
if (idx < 0 || idx >= cmd .length ) {
1293
- console .debug (` reset cursor, idx: ${idx }, cmd.length: ${cmd .length } ` )
1294
1280
_resetCursorPos ()
1295
1281
return
1296
1282
}
@@ -1485,11 +1471,17 @@ const _onInputKeydown = (e: KeyboardEvent) => {
1485
1471
} else if (key === ' arrowright' ) {
1486
1472
_checkInputCursor ()
1487
1473
_cursorGoRight ()
1474
+ } else if (key === ' enter' ) {
1475
+ e .preventDefault ()
1488
1476
}
1489
1477
}
1490
1478
1491
1479
const _onInputKeyup = (e : KeyboardEvent ) => {
1492
1480
let key = e .key .toLowerCase ()
1481
+ if (key === ' enter' ) {
1482
+ e .preventDefault ()
1483
+ return
1484
+ }
1493
1485
let code = e .code .toLowerCase ()
1494
1486
if (key === ' home' || key === ' end' || code === ' altleft' || code === ' metaleft' || code === ' controlleft'
1495
1487
|| ((e .ctrlKey || e .metaKey || e .altKey ) && (key === ' arrowright' || key === ' arrowleft' ))) {
0 commit comments