Skip to content

Conversation

pestctrl
Copy link
Contributor

@pestctrl pestctrl commented Jun 13, 2022

This is a minor bug that has just bothered me for years, and I've finally decided to fix it.

When I run cider-eval-last-sexp twice, the second overlay never shows up. This is because we're letting the hook that's supposed to kill overlay #1 also kill overlay #2. When creating a second overlay right after the first one, we already remove overlay #1 in #'cider--make-result-overlay, and thus we can safely remove #'cider--remove-result-overlay from the post-command-hook.


Previously, if multiple overlays were created one after another that
are meant to last for one command, every second overlay wouldn't show
up. This is because there's a hook in the post-command-hook that will
delete all overlays, and it runs right after the second overlay is
created.

Instead, if we're creating an overlay as we speak (ie. we are in the
function 'cider--make-result-overlay), we already know that the
previous overlay has been deleted, and thus we can remove
'cider--remove-result-overlay from the 'post-command-hook.


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint) which is based on elisp-lint and includes
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

If you're just starting out to hack on CIDER you might find this section of its
manual
extremely useful.

@pestctrl pestctrl force-pushed the consecutive-overlays branch from e9958ba to 3ab39c0 Compare June 13, 2022 23:54
Previously, if multiple overlays were created one after another that
are meant to last for one command, every second overlay wouldn't show
up. This is because there's a hook in the 'post-command-hook that will
delete all overlays, and it runs right after the second overlay is
created.

Instead, if we're creating a new 'result overlay as we speak (ie. we
are in the function 'cider--make-result-overlay), we should call
'cider--remove-result-overlay directly, so that the previous overlay
gets removed AND 'cider--remove-result-overlay  gets removed from the
'post-command-hook.

We can conceptualize this as running the hook early, since we're
deciding to delete the overlay now rather than wait till the
'post-command-hook.
@pestctrl pestctrl force-pushed the consecutive-overlays branch from 3ab39c0 to 87192ea Compare June 14, 2022 00:00
@pestctrl pestctrl closed this Jun 14, 2022
@pestctrl
Copy link
Contributor Author

I will write some tests this weekend, and re-submit the pull request.

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

Successfully merging this pull request may close these issues.

1 participant