Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim.mode = 'Replace' doesn't evaluate to true when using r on its own #9369

Open
kaem-e opened this issue Nov 23, 2024 · 0 comments
Open

vim.mode = 'Replace' doesn't evaluate to true when using r on its own #9369

kaem-e opened this issue Nov 23, 2024 · 0 comments

Comments

@kaem-e
Copy link

kaem-e commented Nov 23, 2024

Encountered a weird bug where, with the following keybinding remap

{
	"key": "n",
	"command": "runCommands",
	"args": { "commands": [ "editor.action.nextMatchFindAction", "closeFindWidget", "extension.vim_escape" ] },
	"when": "editorFocus && vim.mode == 'Normal' && !findWidgetVisible && !(vim.mode == 'Replace')",
},

the vim.mode == 'Replace' wont evaluate to true if I try to r{char}.

furthermore, to work around this, making r start a visual selection first with something like

{ // weird ass workaround to get vim.mode == 'Replace' to work properly. 
	// basically, when starting a replace always make sure that a visual selection of 1 character under the cursor is made
	"key": "r",
	"when": "inputFocus && vim.mode == 'Normal'",
	"command": "vim.remap",
	"args": {
		"after": [ "v", "r" ],
		"silent": true,
	}
},

manages to qualify the vim.mode == 'Replace' clause, suggesting it's a bug where r, when used on its own, doesn't get interpreted as being in replace mode

To Reproduce

  1. paste the json in your keybindings.json
[
	{
		"key": "/",
		"command": "actions.find",
		"when": "editorFocus && vim.mode == 'Normal' && !findInputFocussed && !replaceInputFocussed"
	},
	{
		"key": "/",
		"command": "runCommands",
		"args": { "commands": [ "actions.find", "toggleFindInSelection" ] },
		"when": "editorFocus && (vim.mode == 'VisualLine' || vim.mode == 'Visual') && !findInputFocussed && !replaceInputFocussed"
	},
	{
		"key": "ctrl+/",
		"command": "editor.action.startFindReplaceAction",
		"when": "editorFocus && findWidgetVisible && !replaceInputFocussed "
	},
	{
		"key": "enter",
		"command": "runCommands",
		"when": "editorFocus && findInputFocussed && !replaceInputFocussed",
		"args": { "commands": [ "workbench.action.focusActiveEditorGroup", "extension.vim_escape" ] },
	},
	{
		"key": "shift+n",
		"command": "runCommands",
		"args": { "commands": [ "editor.action.previousMatchFindAction", "extension.vim_escape" ] },
		"when": "editorFocus && findWidgetVisible && !findInputFocussed && !replaceInputFocussed"
	},
	{
		"key": "n",
		"command": "runCommands",
		"args": { "commands": [ "editor.action.nextMatchFindAction", "extension.vim_escape" ] },
		"when": "editorFocus && findWidgetVisible && !findInputFocussed && !replaceInputFocussed"
	},
	{
		"key": "shift+n",
		"command": "runCommands",
		"args": { "commands": [ "editor.action.previousMatchFindAction", "closeFindWidget", "extension.vim_escape" ] },
		"when": "editorFocus && vim.mode == 'Normal' && !findWidgetVisible && !(vim.mode == 'Replace')",
	},
	{
		"key": "n",
		"command": "runCommands",
		"args": { "commands": [ "editor.action.nextMatchFindAction", "closeFindWidget", "extension.vim_escape" ] },
		"when": "editorFocus && vim.mode == 'Normal' && !findWidgetVisible && !(vim.mode == 'Replace')",
	},
]
  1. try replacing a character with n via rn, or N via rN

Environment:

  • Extension (VsCodeVim) version: 1.28.1
  • VSCode version: 1.95.3
  • OS: Windows
@kaem-e kaem-e changed the title vim.mode = 'Replace' doesnt evaluate to true when using r on its own vim.mode = 'Replace' doesn't evaluate to true when using r on its own Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant