-
Notifications
You must be signed in to change notification settings - Fork 45
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: completeFunctionCalls adds brackets when writing JSX #240
base: master
Are you sure you want to change the base?
Conversation
Hi, thanks for your contribution. I'm still on my vacation so I'll test it next week! |
@@ -137,6 +137,12 @@ end | |||
function M.handler(request, response, params) | |||
local requested_bufnr = vim.uri_to_bufnr(vim.uri_from_fname(params.data.file)) | |||
local filetype = vim.bo[requested_bufnr].filetype | |||
local is_valid_context_for_function_snippet = utils.is_valid_context_for_function_snippet( | |||
requested_bufnr, | |||
params.data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After using this PR for a bit, I've noticed that the position here does under some circumstances not get updated between when it first appears as a completion item and when it is chosen as a completion.
For example, when you are in insert mode and press backspace, the results and positions remain the same, which can lead to some unexpected behavior like this (| indicates cursor position):
# go into insert mode
{fooBarBaz|}<Component></Component>
# press backspace once, if you complete now, a snippet is used correctly
{fooBarBa|}<Component></Component>
# press backspace two more times, if you complete now, a snippet is not used
# even though it should be
# because the position is still the same as in step 1, but there is a '<'
# on that position now
{fooBar|}<Component></Component>
The problem could be solved, by querying the current cursor position from nvim here, instead of using the params, but I'm not sure if there is a better solution to this.
Any updates on this? |
This would be a really nice improvement. 🙏 |
Solves #239
Fixes brackets being placed wrongly (for example with JSX and import statements) when complete_function_calls is set to true as described in the linked issue.
Old behavior
New behavior