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

Actions in vim are sometimes captured by Slumber #351

Closed
LucasPickering opened this issue Aug 27, 2024 · 2 comments · Fixed by #359
Closed

Actions in vim are sometimes captured by Slumber #351

LucasPickering opened this issue Aug 27, 2024 · 2 comments · Fixed by #359
Labels
bug Something isn't working

Comments

@LucasPickering
Copy link
Owner

Did you search for existing issues already?

Yep

Describe the bug
A clear and concise description of what the bug is

Sometimes when entering vim (e.g. to edit the collection file), some vim actions are picked up by Slumber. This means when you exit vim and get back to slumber, the UI state may be different because of hotkeys being hit. For example if you happened to type an "r" while in vim, it may have switched you to the request/response pane.

To Reproduce
Steps to reproduce the behavior

I haven't found a consistent reproduction. Sometimes it happens, sometimes it doesn't.

  1. Edit Collection
  2. Type some stuff into vim
  3. Exit and go back to slumber
  4. Check if UI state changed

Expected behavior
A clear and concise description of what you expected to happen

Actions don't get captured by Slumber

Screenshots
If applicable, add screenshots to help explain your problem

Version (please complete the following information):

  • OS: Macos 14.6.1
  • Terminal: iTerm 3.5.3
  • Slumber Version: 1.8.0

Additional context
Add any other context about the problem here.

@LucasPickering LucasPickering added the bug Something isn't working label Aug 27, 2024
@hans-strudle
Copy link

hans-strudle commented Aug 30, 2024

@LucasPickering saw your reddit post about this issue and took a look and I have gotten the same issue, also on mac myself. I'm just now learning rust but was able to get the keycodes from VIM logged and I seemed to get these keys over and over after editing in vim:
1;95;0c;
the last c would cause the TUI to jump to the Recipe panel, would occasionally get some other gibberish but this string happened all the time.
Some googling suggested that its most likely due to vim plugins and maybe the ~/.vimrc, so I modified the EditorBuilder command to add the args --noplugin -u NONE, which turns off plugins and tell vim to not use any .vimrc.

Example diff:

--- a/crates/slumber_tui/src/lib.rs
+++ b/crates/slumber_tui/src/lib.rs
@@ -420,3 +420,6 @@ impl Tui {
         })?;
-        command.status().context(error_context)?;
+        command
+            .args(["--noplugin", "-u", "NONE"])
+            .status()
+            .context(error_context)?;
         // If the editor was terminal-based it probably dropped us out of the

This gets rid of the issue for me, at the loss of my plugins and colorscheme etc, altho that should be acceptable for just a quick edit I hope. Haven't tested this deeply but wanted to share my findings with you, also super cool project I love it!

@LucasPickering
Copy link
Owner Author

@hans-strudle Thanks for finding this! I didn't even think to look at my vimrc, I set that up like 5 years ago and haven't thought about it since 😛. I'll have to do some deeper debugging and see what exactly in there is causing the issue.

LucasPickering added a commit that referenced this issue Sep 1, 2024
Vim dumps out some garbage events on exit, which causes strange behavior in Slumber.

Closes #351
LucasPickering added a commit that referenced this issue Sep 1, 2024
Vim dumps out some garbage events on exit, which causes strange behavior in Slumber.

Closes #351
LucasPickering added a commit that referenced this issue Sep 1, 2024
Vim dumps out some garbage events on exit, which causes strange behavior in Slumber.

Closes #351
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Oct 13, 2024
## [2.1.0] - 2024-09-27

### Added

- Use `SLUMBER_CONFIG_PATH` to customize configuration (_not_ collection) file path [#370](LucasPickering/slumber#370)
- Add a dynamic variant to `!select` chain type, allowing your collection to present a list of values driven from the output of another chain. (thanks @anussel5559)
  - [See docs for more](https://slumber.lucaspickering.me/book/api/request_collection/chain_source.html#select)
- Cancel in-flight requests with the `cancel` action (bound to escape by default)
- Add `slumber new` subcommand to generate new collection files [#376](LucasPickering/slumber#376)
- Add `default` field to profiles
  - When using the CLI, the `--profile` argument can be omitted to use the default profile
- Reset edited recipe values to their default using `z`
  - You can [customize the key](https://slumber.lucaspickering.me/book/api/configuration/input_bindings.html) to whatever you want
- Add `selector_mode` field to chains, to control how single vs multiple results from a JSONPath selector are handled
  - Previously, if a selector returned multiple results, an error was returned. Now, the result list will be rendered as a JSON array. To return to the previous behavior, set `selector_mode: single` in your chain.
  - [See docs for more](https://slumber.lucaspickering.me/book/api/request_collection/chain.html#selector-mode)

### Changed

- Update file locations to adhere to XDG spec on Linux [#371](LucasPickering/slumber#371)
  - Move config file to [config dir](https://docs.rs/dirs/latest/dirs/fn.config_dir.html), which remains the same on MacOS/Windows but changes on Linux. For backward compatibility, the previous path ([data dir](https://docs.rs/dirs/latest/dirs/fn.data_dir.html)) will be checked and used if present
  - Move log files to [state dir](https://docs.rs/dirs/latest/dirs/fn.state_dir.html) on Linux and [cache dir](https://docs.rs/dirs/latest/dirs/fn.cache_dir.html) on MacOS/Windows
  - Database file remains in [data dir](https://docs.rs/dirs/latest/dirs/fn.data_dir.html) on all platforms
- Create config file on startup if it doesn't exist
- If config file fails to load during TUI startup, display an error and fall back to the default, rather than crashing
- De-deprecate `{{env.VARIABLE}}` template sources
  - They'll remain as a simpler alternative to `!env` chains

### Fixed

- Updated the Configuration docs to remove the non-existent `slumber show dir` command (thanks @SVendittelli)
- Retain all request history when collection file is reloaded
  - Previously, pending and failed requests were lost on reload within a single session. These will still be lost when a session is exited.
- Fix serialization of query parameter lists
- Don't update UI for useless events (e.g. cursor moves)

## [2.0.0] - 2024-09-06

2.0 is headlined by a highly requested feature: one-off edits to recipes! If you need to tweak a query parameter or edit a body, but don't want to modify your collection file, you can now highlight the value in question and hit `e` to modify it. The override will be retained until you modify the collection file or exit Slumber, at which point it will revert to its original value.

Aside from the major new feature, there is one breaking change to the escape syntax of templates. The old backslash-based syntax was fraught with edge cases and unpredictable behavior. This new syntax is simpler to use, simpler to implement, and much more bulletproof. This syntax was rare to use to begin with, so **most people will be unimpacted by this change.**

Here's the full list of changes:

### Breaking

- Replace backslash escape sequence with a simpler scheme based on `_`
  - For example, previously a key would be escaped as `\{{`. This introduced complexities around how to handle additional backslashes, and also required doubling up backslashes in YAML
  - The new equivalent would be `{_{`, which parses as `{{`
  - The goal of this change is to make escaping behavior simpler and more consistent
  - For more info on the new behavior, [see the docs](https://slumber.lucaspickering.me/book/api/request_collection/template.html#escape-sequences)
- Remove `--log` CLI argument
  - See note on log files in Changed section for why this is no longer necessary

### Added

- Edit recipe values (query params, headers, etc.) in the TUI to provide one-off values
  - Press `e` on any value you want to edit (you can [customize the key](https://slumber.lucaspickering.me/book/api/configuration/input_bindings.html))
- Add `editor` field to the config, allowing you to customize what editor Slumber opens for in-app editing
  - [See docs for more](https://slumber.lucaspickering.me/book/api/configuration/editor.html)
- Add `!select` chain type, allowing your collection to prompt the user to select a value from a static list (thanks @anussel5559)
  - [See docs for more](https://slumber.lucaspickering.me/book/api/request_collection/chain_source.html#select)

### Changed

- `!json` bodies are now prettified when sent to the server
- Use `vim` as default editor if none is configured
- Move logs back to a shared file
  - They had been split into one file per session, which made them hard to find
  - The file is now eventually deleted once it exceeds a certain size

### Fixed

- Fix basic auth being label as bearer auth in Recipe Authentication pane
- Use correct binding for `search` action in the placeholder of the response filter textbox
  - Previously it was hardcoded to display the default of `/`
- Fix response body filter not applying on new responses
- Support quoted arguments in editor commands
- Fix certain UI values not persisting correctly
- Propagate unconsumed key events from text boxes
  - E.g. F5 will now refresh the collection while a text box is in focus
- Redraw TUI when terminal is resized
- Clamp text window scroll state when window is resized or text changes
- Fix extraneous input events when exiting Vim [#351](LucasPickering/slumber#351)
- Improve performance and fix crashes when handling large request/response bodies [#356](LucasPickering/slumber#356)
  - Further improvements for large bodies will be coming in the future

## [1.8.1] - 2024-08-11

This release is focused on improving rendering performance. The TUI should generally feel more polished and responsive when working with large bodies, and CPU usage will be much lower.

### Added

- Add `debug` configuration field, to enable developer information

### Fixed

- Reduce CPU usage while idling
  - Previously, Slumber would re-render every 250ms while idling, which could lead to high CPU usage, dependending on what's on the screen. Now it will only update when changes occur, meaning idle CPU usage will be nearly 0
- Fix backlogged events when renders are slow
  - If renders are being particular slow, it was previously possible for input events (e.g. repeated scrolling events) to occur faster than the UI could keep up. This would lead to "lock out" behavior, where you'd stop scrolling and it'd take a while for the UI to catch up.
  - Now, the TUI will skip draws as necessary to keep up with the input queue. In practice the skipping should be hard to notice as it only occurs during rapid TUI movements anyway.
- Improve rendering performance for large bodies and syntax highlighting
- Fix incorrect decoration in folder tree visualization

## [1.8.0] - 2024-08-09

The highlight (no pun intended) of this release is syntax highlighting. Beyond that, the release contains a variety of small fixes and improvements.

### Added

- Add syntax highlighting to recipe, request, and response display [#264](LucasPickering/slumber#264)

### Changed

- Change layout of internal database for request and UI state storage
  - This _shouldn't_ have any user impact, it's just a technical improvement. If you notice any issues such as missing or incorrect request history, please [let me know](https://github.com/LucasPickering/slumber/issues/new?assignees=&labels=bug&projects=&template=bug_report.md)
- Upgrade to Rust 1.80
- Disable unavailable menu actions [#222](LucasPickering/slumber#222)
- Support template for header names in the `section` field of `!request` chains
- Expand `~` to the home directory in `!file` chain sources and when saving response body as a file
- Ignore key events with additional key modifiers
  - For example, an action bound to `w` will no longer match `ctrl w`
- Actions can now be unbound by specifying an empty binding
  - For example, binding `submit: []` will make the submit action inaccessible

### Fixed

- Fix `cargo install slumber` when not using `--locked`
- Don't type in text boxes when modifiers keys (other than shift) are enabled
  - Should mitigate some potential confusing behavior when using terminal key sequences
- Query parameter and header toggle rows no longer lose their state when switching profiles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants