Skip to content

Conversation

@miya
Copy link
Member

@miya miya commented Jan 14, 2026

@miya miya requested a review from yuki-takei January 14, 2026 06:49
@miya miya self-assigned this Jan 14, 2026
const onSaveRef = useRef(onSave);
useEffect(() => {
onSaveRef.current = onSave;
}, [onSave]);
Copy link
Member Author

@miya miya Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useRef を用意し、引数から渡ってきた onSave を常に最新のも参照させるための useEffect

};
settingKeyMap(keymapMode);
}, [keymapMode, onSave]);
}, [keymapMode]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この useEffect の依存配列から引数から渡ってきた onSave を抜いて keymapExtension state を複数回更新させないように修正

setKeymapExtension(await getKeymap(name, stableOnSave));
};
settingKeyMap(keymapMode);
}, [keymapMode, onSave]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

バグの原因

useKeymapExtension フック内で onSave が useEffect の依存配列に入っていたことで onSave が変更される度に keymapExtension state が更新されていた。keymapExtension が更新されることで下記の useEffect により codeMirrorEditor?.appendExtensions が呼ばれていたことが原因

useEffect(() => {
if (keymapExtension == null) {
return;
}
const cleanupFunction = codeMirrorEditor?.appendExtensions(
Prec.low(keymapExtension),
);
return cleanupFunction;
}, [codeMirrorEditor, keymapExtension]);
};

@yuki-takei yuki-takei merged commit 1314060 into master Jan 15, 2026
26 checks passed
@yuki-takei yuki-takei deleted the fix/176960-vim-input-mode-issue branch January 15, 2026 12:40
@github-actions github-actions bot mentioned this pull request Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

キーバインドをVimにした際、入力モードがすぐに終了してしまう

3 participants