Giter Club home page Giter Club logo

Comments (5)

ember91 avatar ember91 commented on June 14, 2024 1

Thanks for the response! Perhaps waiting for tree sitter is the right way to go. It seems like it may appear in VS code in the future. I'll report the issue there as well, which may speed up the process.

from better-cpp-syntax.

ember91 avatar ember91 commented on June 14, 2024 1

The issue has already been reported in VS code here, which moved here, as previously mentioned by Jeff.

from better-cpp-syntax.

jeff-hykin avatar jeff-hykin commented on June 14, 2024 1

Good news. I've been refactoring the code the last few days and I discovered a way to do it.

It turns out the legacy code is not actually using a range, they're instead just using a very long normal pattern matcher for only the beginning of the class.

It is still going to take a bit to implement the fix, but at least it's possible. 👍

from better-cpp-syntax.

jeff-hykin avatar jeff-hykin commented on June 14, 2024

Just for reference (for other people) fixing this issue also would fix the issue posted here atom/language-c#245

I've got bad news though :/

TextMate grammars have basically two ways of matching things

  1. Regex match
  2. Range (start and end) match
  • Start must be a Regex match
  • End must be a Regex match

The caveat is, the Regex match for TextMate cannot match newlines. (This is something inherently limiting about the TextMate implementation.) If something contains newlines, say a class definition:

class A {
    // newline 
}

then you're supposed to use a Range.

Right now the range start is basically class { and the range end is }, but since there's no way to include newlines in the start, theres no straightforward way to match the class : \n*parents* { at the start. We could remove the class {, } range, but it is also used to style things like public:, and private: which are only allowed in class/struct definitions.

Now, their might be a clever way to get a make-shift solution and get around this which I'll try to work on, but the root problem is that the syntax highlighting is inherently limited. This is something a Tree Sitter would fix and this issue should additionally be logged on the VS Code repo.

Ideas for a hacky solution:

  • Have class A be the start, and } be the end, and then just guess-style for the first { and the inheritance
  • Have class be the start and have } be the end, then have a internal range that starts with lookBehindFor(class) and finds all the inherited classes and ends with {

from better-cpp-syntax.

jeff-hykin avatar jeff-hykin commented on June 14, 2024

I published a fix this with version 1.6.1 and pushed it just now. I'm going to do more work on it since the whole class pattern/tagging needs to be updated, but for usage purposes it should at least be highlighted now!

from better-cpp-syntax.

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.