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

fix: correctly restore cursor position in original window #2336

Merged
merged 2 commits into from
May 24, 2023

Conversation

cristiansofronie
Copy link
Contributor

@cristiansofronie cristiansofronie commented Jan 19, 2023

Description

In some conditions such as when calling man_pages or help_tags the cursor
position in the original window is wrongly restored. This bug was introduced by
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 and seems to be caused by some weird
"race condition".

Fixes #2319

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • Before introducing this change man_pages and help_tags move the cursor to
    the right when you hit Enter. With this change this doesn't happen. The commit
    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 that introduced this bug tried to fix
    the fact that when you leave Telesope with from insert mode the cursor is
    moved to the left by 1 position. But this made it so that under some circumstances
    the opposite happens, that is for the cursor to be moved to the right. This
    might have something to do with the Vim loop.
  • vim.api.nvim_put on selection works correctly before and after the cursor

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@cristiansofronie
Copy link
Contributor Author

This attempt at a fix introduces another bug. With help_tags when you are
already in a help window it doesn't scroll correctly to the given tag.

@cristiansofronie
Copy link
Contributor Author

The thing that I find always works is to ensure that you always are in normal
mode before exiting Telescope.

@Conni2461
Copy link
Member

thanks for the PR :)

i am super nervous at touching any of that code, its always really flaky and i dont know why. something always breaks ^^ but can you fix stylua ci and i ran this for a day or two and see how it works

thanks :) also sorry for the late response.

@Conni2461
Copy link
Member

thanks for the PR :)

i am super nervous at touching any of that code, its always really flaky and i dont know why. something always breaks ^^ but can you fix stylua ci and i ran this for a day or two and see how it works

thanks :) also sorry for the late response.

me irl ... so sad.

yeah so obviously i haven't ran this for a day or two. i am going to test it now and then maybe merge, we'll see (hopefully earlier than 3 months)

@Conni2461 Conni2461 merged commit 3f1b579 into nvim-telescope:master May 24, 2023
@Conni2461
Copy link
Member

thanks again :)

@Conni2461
Copy link
Member

needs to be reverted because it breaks custom actions that rely that the windows are closed after action.close()

Conni2461 added a commit that referenced this pull request May 25, 2023
Conni2461 added a commit that referenced this pull request May 25, 2023
Conni2461 added a commit that referenced this pull request May 25, 2023
abelmul pushed a commit to abelmul/telescope.nvim that referenced this pull request Jun 6, 2023
abelmul pushed a commit to abelmul/telescope.nvim that referenced this pull request Jun 6, 2023
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.

strange cursor move when telescope closes
2 participants