GithubHelp home page GithubHelp logo

Comments (4)

shaunlebron avatar shaunlebron commented on May 31, 2024

We can fix this by not removing unmatched delimiters. I think this solves the problem completely for single line strings, because delimiters are then only removed when they fall at the end of a line. And by definition of a single string, the contents of the string will always end with a quote, preventing its removal.

This doesn't help multiline strings:

(def foo

  "(a b)
      c")

Inserting two quotes on the second line results in this:

(def foo
  ""
  "(a b
      c")

So I think the true solution is to just hold prevent processing if there is an unmatched quote anywhere in the file.

from parinfer.js.

shaunlebron avatar shaunlebron commented on May 31, 2024

Another breaking bug caused by quotes in comments being overtaken by strings:

Steps to recreate. Delete the quote at the end of line 2, and reinsert it.

(def foo
  ""
  "(a b)
      c" ;; "
   c)

You will get this:

(def foo
  ""
  "(a b
      c" ;; ")
   c)

from parinfer.js.

shaunlebron avatar shaunlebron commented on May 31, 2024

crazy idea: detect if there are an even number of unescaped quotes in a string. if there aren't, escape the last one so that an imbalanced string state will be guaranteed to pass through it.

with all these crazy cases coming up, maybe parinfer should just be isolated to a "restructure selection by indentation" function in an editor.

from parinfer.js.

shaunlebron avatar shaunlebron commented on May 31, 2024

escaping quotes in comments was a bad idea, we can't quickly comment/uncomment a line of code with a string in it.

I will just make a note that strings must be balanced in comments

from parinfer.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.