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 infinite-loop in lsp-bridge-elisp-get-filepath when yaml-mode #1151

Merged
merged 1 commit into from
Jan 19, 2025

Conversation

i-aki-y
Copy link
Contributor

@i-aki-y i-aki-y commented Jan 18, 2025

The lsp-bridge-elisp-get-filepath appears to enter infinite-loop when yaml-mode.

How to reproduce the problem

  1. setup a yaml lsp server (npm install -g yaml-language-server)
  2. open a yaml file (test.yaml)
  3. add some valid items (a: 1)
  4. move the cursor to beginning-of-buffer
  5. type any characters, see the example below.

ex.

  <- type here in yaml model
a: 1
b: 2
c: 3

About the fix

In the while loop of the lsp-bridge-elisp-get-filepath function, if file-beg variable has 1 and the substring does not match any existing file paths, the result of (goto-char (1- file-beg)) would not change cursor position (file-beg is still 1) and repeat the same loop infinitely.

I added a check to see whether the file-beg variable reaches the beginning-of-buffer or not.

I could not observe the problem in other language like python-mode.
The yaml seems to be special because a string without quotes (" or ') could be recognized as a valid string. In other languages, strings would be enclosed by quotes "abc" or 'abc', which may avoid the variable file-beg reaches to 1

I would appreciate it if you could review this PR.

@manateelazycat manateelazycat merged commit 59a956f into manateelazycat:master Jan 19, 2025
1 check passed
@manateelazycat
Copy link
Owner

Thanks for patch

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