copilot-cmp
copilot-cmp copied to clipboard
fix pair does not work properly
I tried the example mentioned at README, but the behavior seems not properly:
I am using ConfirmBehavior.Replace and default config for copilot-cmp
From what I see in the code the whole fix pair thing is broken, unfortunately :( It doesn't know about ', ", language-specific pairs (i.e. Python's """
/ ''''
or Lua's [===[
). Also, it does not account for the inline comments or text in quotes (hence if there's an unclosed pair character in the string, sort of if ("A sad smile (" ==
you will get an extra )
).
From what I see in the code the whole fix pair thing is broken, unfortunately :( It doesn't know about ', ", language-specific pairs (i.e. Python's
"""
/''''
or Lua's[===[
). Also, it does not account for the inline comments or text in quotes (hence if there's an unclosed pair character in the string, sort ofif ("A sad smile (" ==
you will get an extra)
).
This kind of hits the nail on the head. Fix pairs exists to address a problem that really should't be this plugin's responsibility. Keeping up with every language's unique pair strings isn't really reasonable. I would accept PRs for something like this but haven't seen any. I'm debating taking it out completely and maybe including a config option to allow people to inject their own handlers for fix pairs type functionality, but I had extensive support for this type of thing in the past, but it didn't seem like people were too interested in using it since there were still numerous issues regarding things that should be addressed using it.
From what I see in the code the whole fix pair thing is broken, unfortunately :( It doesn't know about ', ", language-specific pairs (i.e. Python's
"""
/''''
or Lua's[===[
). Also, it does not account for the inline comments or text in quotes (hence if there's an unclosed pair character in the string, sort ofif ("A sad smile (" ==
you will get an extra)
).This kind of hits the nail on the head. Fix pairs exists to address a problem that really should't be this plugin's responsibility. Keeping up with every language's unique pair strings isn't really reasonable. I would accept PRs for something like this but haven't seen any. I'm debating taking it out completely and maybe including a config option to allow people to inject their own handlers for fix pairs type functionality, but I had extensive support for this type of thing in the past, but it didn't seem like people were too interested in using it since there were still numerous issues regarding things that should be addressed using it.
Why not just count the paired chars, and add the text after cursor if the count is incorrect. Like this:
if not pattern.check_pairs(text) then
if pattern.check_pairs(text .. ctx.cursor_after_line) then
text = text .. ctx.cursor_after_line
end
end