Skip to content

Conversation

@raymond-w-ko
Copy link
Contributor

One thing that has frustrated me greatly is that Copilot cannot balance parentheses et al, even when using VSCode + the official plugin, which is the golden standard. Since I program in Clojure for work, this is maddening as you have to these fix missing or extra char pairs. Almost all lisp editors run into issues once in this unbalanced state.

Thankfully, the brokenness follows a pattern where I think it is only the suffix portion that is mismatched, meaning it can be algorithmically fixed. I attempt to do so here.

There are other two changes:

  1. I coerce all Clojure modes to just clojure as that is the only official language ID.
  2. I rewrote the code so that save-excursion is in the outer loop and save-restriction is inside, as recommended by the docs. I also eliminated multiple calls as a micro-optimization.

@zerolfx
Copy link
Collaborator

zerolfx commented Jul 15, 2023

LGTM! Great work!

I can't push to your branch, please resolve the conflict and I'll merge it soon.

also rewrite to use save-excursion in the outer layer, and
save-restriction in the inner layer, as recommended by the docs.
@raymond-w-ko
Copy link
Contributor Author

There is still one bug I'm working on, so let me see if I can fix it:

(defun add () | 
  )(EOF)

@raymond-w-ko
Copy link
Contributor Author

I had to rewrite portions to deal with pairs inside strings, so I'm not 100% as I haven't used it for my work. However, it should be ready to merge.

@zerolfx zerolfx merged commit 6ee80a7 into copilot-emacs:main Jul 17, 2023
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