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

vi-mode - Bug - Fix freeze when using _i"/_a" in escaped string #1716

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

LeeLaffan
Copy link
Contributor

@LeeLaffan LeeLaffan commented Dec 26, 2024

Change Description

The fix is for the bug in Issue #1657.
This affects code in operator pending mode, so the editor will freeze when using:

  • v i/a "
  • c i/a "
  • d i/a "
  • y i/a "

This occurs as when the escape character is found, it does not move the character forward/back, causing an infinite loop of finding the escape char.

As shown in this seek backward example, I have changed it to skip over 2 chars (the escape and the quote char). I did the same for when seeking forward.

  ;; Before
  ((and escape-char)
    (char= prev-char escape-char))
   
  ;; After 
  ((and escape-char 
            (character-at point -2) ;; Bound check
            (char= (character-at point -2) escape-char))
    (character-offset point -2))

This behaviour to ignore escape chars, which seems intended for Lem's vi-mode(just bugged), does match vanilla vim so good to have.

Testing

I have updated the tests to account for this case.
This image shows the rendered test outputs which can help you decipher the string in the tests in you want:
Tests Passing

Other Bugs

I found some more bugs that are existing already with this functionality, but no more editor freezes, just unexpected behavious in some cases.
I hope to fix them with a bit of changes to the logic around finding quotes specifically.

  • Both have different but unexpected behavior when they are before the first quote/after the last quote
  • Both do not gracefully fail in all cases(one "). This is particularly annoying when doing d_" or c_" where you don't have the visual feedback

Feature

  • Both do not mimic vim seek ahead in line with operator pending mode

@cxxxr cxxxr merged commit 8937771 into lem-project:main Dec 27, 2024
2 checks passed
@cxxxr
Copy link
Member

cxxxr commented Dec 27, 2024

Thank you!

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.

2 participants