Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.63k stars 1.96k forks source link

Escape key closes environment editor modal in vim mode #4877

Open ian-h-chamberlain opened 2 years ago

ian-h-chamberlain commented 2 years ago

Expected Behavior

When editing an environment, I'd like to use Esc to exit insert mode, without closing the modal. Ideally, when pressing the escape key:

In practice that might be tricky, so maybe an alternative would be to simply pass the escape keypress to the vim mode handler and prevent closing of the modal with it entirely (in which case, hopefully another keyboard shortcut could be used to close it? :q or :wq would be nice).

Actual Behavior

Pressing escape closes the modal, even when in insert mode.

Reproduction Steps

  1. Open Preferences > General
  2. Set Text Editor Key Map to Vim
  3. Open Manage Environments (cmd+E)
  4. press i and type some text OR select some text
  5. press Escape

Is there an existing issue for this?

Additional Information

Previously closed issue (although seemingly with slightly different behavior): #208

Perhaps this is a regression from the PR delivered against that issue (#1429)?

Insomnia Version

2022.4.1

What operating system are you using?

macOS

Operating System Version

macOS Monterey 12.4 (21F79)

Installation method

Homebrew

Last Known Working Insomnia version

Unsure, but I do think it previously worked as expected.

drice commented 2 years ago

I'm having the same issue. I also believe this used to work as expected. I had to switch back to normal keybindings just to edit the environments.

filfreire commented 2 years ago

Hi @ian-h-chamberlain (and @drice) thanks for reporting this issue!

We're looking to improve how we handle shortcuts (e.g. like Escape to close a modal and others) while we have something focused the the environment editor or other modals.

In the meantime and as an alternative to unblock you, I suggest you could change the keyboard shortcut to close modals to another key that is not Escape:

Screenshot_2022-06-22_at_15_43_28

ian-h-chamberlain commented 2 years ago

@filfreire thank you!! It's not a perfect solution, but this is a decent enough workaround for now and at least enables reasonably editing of the modal contents in Vim mode. I set a shortcut ^+C to close the modal and it works for now, although I do think something like :q or :wq would be preferable in the long run.

ian-h-chamberlain commented 1 year ago

I recently updated to 2022.7.1, and this workaround no longer seems to apply ☹️

I can't find any "Close Modal" shortcut anymore, and actually it seems like the shortcuts are now backwards from what I had previously configured (I have to use ctrl-C to exit insert mode, and Esc closes the modal instead of returning to Normal mode)! I am guessing this is as a result of #4937 (and perhaps more specifically, 6de1dbdbcf4a7849be2ab4f15a9bd7752344a4b4)

Is there any way users could at least have the option to reconfigure the "close modal" shortcut to restore the previous workaround? Fixing <Esc> returning to normal mode would also be greatly appreciated.

mattmannion commented 1 year ago

I can confirm that <ESC> no longer drops you into NORMAL mode and you must resort to <C-c> instead.

omaryoussef commented 1 year ago

Can confirm in 2022.7.5 "Close Modal" is not there anymore, this bug is incredibly annoying I've had to switch the keymaps back to normal.

mschmnet commented 1 year ago

It's great that Insomnia has Vim mode (Postman doesn't), but this makes it a little unpleasant. The current status on my machine (macOS) is the same as @mattmannion and @ian-h-chamberlain report. Is there any forecast when this will be addressed? Thank you very much.

LoganEarl commented 1 year ago

I am having the same problem. I would love to try the workaround where you disable the close modal key bind, but as stated by others that setting appears to be missing.

Samuelfaure commented 1 year ago

Thank you for dealing with this issue, Insomnia is great to use, except this environment modal, which is driving me i n s a n e

davehouser1 commented 1 year ago

Bump on this, is there a reason this keyboard shortcut was removed? Using Ctrl+c really messes up my flow. Can this be fixed for the next release please?

ian-h-chamberlain commented 1 year ago

I got frustrated enough and decided to try and fix this myself, after all this time (took me long enough)! Hopefully a maintainer can take a look at #6573 and see if they're happy with my solution.

Edit: got pointed to https://github.com/Kong/insomnia/pull/6518#issuecomment-1735165221 which references #6511 and #6370

Linking them here hopefully as a reminder to consider vim keybinds as well with this new refactor of modal closing... Not sure what the timeline is on those changes but 🤞 hopefully will also address this isssue!

ttelford commented 7 months ago

I'll chime in and say this is also driving me to madness: I've had to modify environments up to three or four times because pressing the esc key to leave 'edit' mode of vi is so much a part of my typing behavior that I end up erasing all of the work I've made in insomnia's environment mode several times per session.

It's becoming incredibly maddening to edit → esc → lose work → curse Insomnia → repeat for several cycles every time I have to use the tool. Muscle memory is a harsh mistress.

I realize that may be more than you'd want to support, but a 'vi-mode' is about mode switching - so it makes sense to use mode switching to do the equivalent things like close a modal dialog. At least in the environment window, if you're using the vi keybinding, it would make sense to require the "close window" keyboard command be inputted from the "command mode", not from any mode. (ie. vi is a modal keyboard input, make sure "command" inputs are from the "command" mode!).