mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
修复了前端输入中文字符再删除会出现的bug
具体的bug复现,见:https://github.com/blueloveTH/pocketpy/issues/50
This commit is contained in:
parent
06d486d2a2
commit
2fd9879eec
@ -145,7 +145,12 @@ function term_init() {
|
|||||||
case '\u007F': // Backspace (DEL)
|
case '\u007F': // Backspace (DEL)
|
||||||
// Do not delete the prompt
|
// Do not delete the prompt
|
||||||
if (term._core.buffer.x > 4) { // '>>> ' or '... '
|
if (term._core.buffer.x > 4) { // '>>> ' or '... '
|
||||||
term.write('\b \b');
|
var re=/[^\u4E00-\u9FA5]/;
|
||||||
|
if (re.test(command.charAt(command.length-1))){//判断前一个字符是否为中文
|
||||||
|
term.write('\b \b');//false
|
||||||
|
}else{
|
||||||
|
term.write('\b\b \b');//中文占两个字节,ascii字符占一个字节
|
||||||
|
}
|
||||||
if (command.length > 0) {
|
if (command.length > 0) {
|
||||||
command = command.substr(0, command.length - 1);
|
command = command.substr(0, command.length - 1);
|
||||||
}
|
}
|
||||||
@ -158,4 +163,4 @@ function term_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user