Broken Vim Langmap

In the recent update, Obsidian has updated its codemirror-vim dependency.

However, it looks like someone at Obsidian has modified the code and introduced a bug, breaking a certain functionality of codemirror-vim.

In particular, when I open /lib/codemirror/vim.js in the inspect window, line 1133 reads:

return { keymap: keymap, string: langmapString, remapCtrl: remapCtrl };

The remapCtrl: remapCtrl part is incorrect. At the same time, it’s not found on the codemirror-vim GitHub repository, nor on any released version on the npm registry. I know that for a fact, because it’s part of my own tested code and I checked on all the mentioned places just to make sure.

To me, it looks like an attempt to satisfy a typescript warning.

This addition, however, completely disables langmaps from being used. Since remapCtrl is actually not defined in the scope of that function, any attempts to set a new langmap fail.

This line should instead be:

return { keymap: keymap, string: langmapString };

If my suspicion about typescript is correct, I would recommend adding a @ts-ignore directive or hard-coding remapCtrl: false. The reason why remapCtrl not being returned here is not a problem, is because it is set elsewhere in the code.

Steps to reproduce

  1. Enable Vim mode in Obsidian settings
  2. Press : to write a command
  3. Write langmap=aa
  4. Click the enter key to execute the command

Did you follow the troubleshooting guide? [Y/N]

Yes

Expected result

The command is executed with no output and a dummy langmap is applied that remaps a to a (so nothing visibly changes).

Actual result

Error message:
vim.js:1133 Uncaught ReferenceError: remapCtrl is not defined

Environment

SYSTEM INFO:
	Obsidian version: v1.7.4
	Installer version: v1.4.14
	Operating system: Windows 10 Home 10.0.19045
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

thanks, we will double check this.

Thanks! We maintain a fork of the vim plugin so patches need to get applied manually. This change got missed in the process.

Thank you for the quick replies!

will be fixed 1.7.5.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.