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 pair does not work properly #81

Open
fecet opened this issue Jul 18, 2023 · 3 comments
Open

fix pair does not work properly #81

fecet opened this issue Jul 18, 2023 · 3 comments

Comments

@fecet
Copy link

fecet commented Jul 18, 2023

I tried the example mentioned at README, but the behavior seems not properly:
cop

I am using ConfirmBehavior.Replace and default config for copilot-cmp

@naquad
Copy link

naquad commented Jul 20, 2023

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 ) ).

@zbirenbaum
Copy link
Owner

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 ) ).

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.

@KurisuNya
Copy link

KurisuNya commented Nov 26, 2023

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 ) ).

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

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

No branches or pull requests

4 participants