Coder Social home page Coder Social logo

`PascalCase` matches one word about dial.nvim HOT 4 OPEN

monaqa avatar monaqa commented on August 27, 2024
`PascalCase` matches one word

from dial.nvim.

Comments (4)

monaqa avatar monaqa commented on August 27, 2024

Thanks for the report. You are right, it is inconvenient.
However, I am not sure how to solve this problem, because it is not obvious how to handle a sequence of uppercase letters in PascalCase.
For example, if I want to change the word "LicenseMIT" from PascalCase to snake_case, how should that be handled? What about the case of "ParseCLanguage"?

from dial.nvim.

kawarimidoll avatar kawarimidoll commented on August 27, 2024

Using Regex Lookahead, a sequence of capital letters can be considered a single word.
Here is an example in JavaScript:

const regex = /[A-Z]([A-Z](?![a-z]))+|[A-Z][a-z]*/g

'LicenseMIT'.match(regex)
// -> ['License', 'MIT']

'ParseCLanguage'.match(regex)
// -> ['Parse', 'C', 'Language']

'JSONToYAMLConverter'.match(regex)
// -> ['JSON', 'To', 'YAML', 'Converter']

In this case, however, there are some probrems.

  • The capital parts cannot be restore once convert to snake_case: LicenseMIT -> license_mit -> LicenseMit
  • The sequence of capital-only-word cannot be detect: JSONYAMLConverter -> jsonyaml_converter

It is a difficult problem and it may good to ignore the word that has a sequence of capital letters.

I reported this issue because the behavior was different from the help.

from dial.nvim.

monaqa avatar monaqa commented on August 27, 2024

Yes, as you say, the current implementation is compatibility oriented.
However, the word detection algorithm could use a little more improvement. It may be possible to sacrifice compatibility for greater convenience.

from dial.nvim.

RobertAudi avatar RobertAudi commented on August 27, 2024

@monaqa A "potential" solution/workaround could be to implement something similar to ActiveSupport::Inflections#acronym and then keep the current algorithm as it is 🤔

from dial.nvim.

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.