update at 2025-11-09 22:04:12

This commit is contained in:
douboer
2025-11-09 22:04:12 +08:00
parent 36c97b0616
commit 172f68ac37
14 changed files with 469 additions and 1431 deletions

36
main.ts
View File

@@ -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' &&