fix infinite-loop in lsp-bridge-elisp-get-filepath
when yaml-mode
#1151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
lsp-bridge-elisp-get-filepath
appears to enter infinite-loop when yaml-mode.How to reproduce the problem
npm install -g yaml-language-server
)test.yaml
)a: 1
)ex.
About the fix
In the while loop of the
lsp-bridge-elisp-get-filepath
function, iffile-beg
variable has1
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 still1
) and repeat the same loop infinitely.I added a check to see whether the
file-beg
variable reaches thebeginning-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 variablefile-beg
reaches to1
I would appreciate it if you could review this PR.