update at 2025-11-09 22:04:12
This commit is contained in:
36
main.ts
36
main.ts
@@ -196,24 +196,28 @@ export default class VimIMSwitchPlugin extends Plugin {
|
||||
}
|
||||
this.lastKeyTime = currentTime;
|
||||
|
||||
// 处理ESC键:退出到normal模式
|
||||
// 处理ESC键:只在insert/replace模式下才切换输入法
|
||||
if (event.key === 'Escape') {
|
||||
// 退出insert模式前,先保存当前输入法状态
|
||||
const beforeIM = await this.runCmd(this.fcitxRemotePath, ["-n"]);
|
||||
const currentIMName = beforeIM.trim();
|
||||
|
||||
// 检查当前输入法是中文还是英文
|
||||
if (currentIMName === this.settings.chineseInputMethod) {
|
||||
this.lastInsertModeIMStatus = IMStatus.Activate;
|
||||
console.log('🔤 [VimIMSwitch] ESC → English (saved Chinese)');
|
||||
} else {
|
||||
this.lastInsertModeIMStatus = IMStatus.Deactivate;
|
||||
console.log('🔤 [VimIMSwitch] ESC → English (saved English)');
|
||||
// 只有在insert或replace模式下按ESC才需要处理输入法
|
||||
if (this.currentVimMode === 'insert' || this.currentVimMode === 'replace') {
|
||||
// 退出insert模式前,先保存当前输入法状态
|
||||
const beforeIM = await this.runCmd(this.fcitxRemotePath, ["-n"]);
|
||||
const currentIMName = beforeIM.trim();
|
||||
|
||||
// 检查当前输入法是中文还是英文
|
||||
if (currentIMName === this.settings.chineseInputMethod) {
|
||||
this.lastInsertModeIMStatus = IMStatus.Activate;
|
||||
console.log('🔤 [VimIMSwitch] ESC → English (saved Chinese)');
|
||||
} else {
|
||||
this.lastInsertModeIMStatus = IMStatus.Deactivate;
|
||||
console.log('🔤 [VimIMSwitch] ESC → English (saved English)');
|
||||
}
|
||||
|
||||
// 切换到英文输入法
|
||||
this.currentVimMode = 'normal';
|
||||
await this.deactivateIM();
|
||||
}
|
||||
|
||||
// 切换到英文输入法
|
||||
this.currentVimMode = 'normal';
|
||||
await this.deactivateIM();
|
||||
// 如果已经在normal模式,ESC键不做任何输入法切换
|
||||
}
|
||||
// 处理进入insert模式的按键(只在normal模式下)
|
||||
else if (this.currentVimMode === 'normal' &&
|
||||
|
||||
Reference in New Issue
Block a user