-
Notifications
You must be signed in to change notification settings - Fork 41
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
"Dangerous quotes" extend to |
?
#213
Comments
to fix your trouble try download this fix, i see it in another issue, |
|
If parinfer.js doesn't have a mode or configuration for Common Lisp yet, then this is a downstream problem I'm seeing in Spacemacs. Could be in parinfer-rust-emacs or parinfer-rust-mode. This could still come up here for similar reasons if you later add Common Lisp support.
Example based on https://shaunlebron.github.io/parinfer/#inserting-quotes
Heuristically, based only on the immediately surrounding characters, the odds should be opening: The evens should be closing: Compare that count to just before the user's edit (previous cycle), and we can heuristically guess we're in an inverted string situation. This would be less obvious with fewer of the heuristically-correct strings below the edit, but above the dangerous quote. Maybe there are other cases I haven't accounted for. What should parinfer do in this situation? Maybe a separate question from the heuristics. I think inserting a " just after the edit location (after their cursor) is the most conservative change. The user can see it immediately, and it's not going to corrupt anything far away. They were probably going to type it anyway. A lot of editors automatically insert balanced pairs like this, or have an option to do it. That should be turned off for brackets handled by Parinfer, but maybe Parinfer should balance the If the user really wants to invert a string, they can cut/paste into the balanced pair or something. |
I'm not sure my suggested heuristics here are workable. Even when they work, they might not help that much. |
Unbalanced
|
inside a comment:Maybe similar to the "dangerous quotes" problem with an unbalanced
"
in a comment, but I think this one could come up more often.If so, it should at least be documented along with
"
.The documentation on dangerous quotes suggests that this wouldn't be an issue if we could tell start quotes from end quotes. Not 100% reliable, but usually, you can tell if a
"
starts or ends a string by the immediately surrounding characters. A("
or"
probably starts a string, while a")
or"
probably ends it. On the other hand,|
can occur inside of symbols, so it's not as easy, but again, they're usually on the outside, so a(|
or|
probably starts a symbol, while a|)
or|
probably ends it. You could tally the whole file and see if most of the quotes you think are start quotes look like start quotes and if most of the end quotes look like end quotes. If it's the reverse, you're probably in a temporary inverted situation. Another heuristic might be the relative length of code vs strings.Maybe most of the time you could get buy on these heuristics, but in cases where certainty isn't as high, you could fall back to the current behavior. The user needs to know why this is happening though.
Is it possible for Parinfer to at least report the location of the dangerous
"
or|
so the editor can highlight it? (Or does it do this already?) The Spacemacs Parinfer layer, at least, doesn't handle this very well. It just mysteriously stops working, maybe with a cryptic#<user-ptr...
message that's easy to miss.It would also be nice if there was a way to turn Parinfer off for just a section of the code. Something like a
;; Parinfer: off
and;; Parinfer: on
pair. This would make it easier for the user to find problems with a binary search approach. It would also allow a dangerous"
or|
if the user super needs it for some reason without giving up on Parinfer for the whole file. A;; Parinfer: skip
above a top-level form could also help. It might be easier to implement.The text was updated successfully, but these errors were encountered: