Comments (5)
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.
The issue has already been reported in VS code here, which moved here, as previously mentioned by Jeff.
from better-cpp-syntax.
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.
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
- Regex match
- 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 withlookBehindFor(class)
and finds all the inherited classes and ends with{
from better-cpp-syntax.
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)
- enum not highlighted if followed by type specifier without space between (c++ only)
- Raw strings fail if the last line of the sting includes a comment. HOT 1
- Packs in template template parameter are not highlighted
- field index followed by arrow operator HOT 1
- Coloring gets wrong after finding a single quote character in a raw C++ string HOT 6
- Syntax Highlighter Crashing HOT 4
- Syntax highlighting broken after member function with requires clause with less comparison
- colorization of tab character "\t" in string does not work properly HOT 2
- 改扩展似乎与clang服务器冲突, 会造成clang语言服务器多次崩溃
- Add semantic colorization for c++23 #elifdef and #elifndef HOT 1
- [Suggestion] Highlight `{}` in strings
- Wrong Token Scope for Typename
- new version is not publish to vscode market? HOT 1
- ASM will not end after '#'
- Syntax highlighting is incorrect for valid C header file
- Highlighting Incorrect After Shimming Ostream Operator
- Another conversion bug `$reference(directive)` HOT 1
- Token is not highlighted in a template
- The keyword constexpr is not highlighted HOT 1
- C++ syntax highlighting falls apart after specific struct syntax HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from better-cpp-syntax.