zed icon indicating copy to clipboard operation
zed copied to clipboard

Syntax Tag for elements after two or more scope resolution operators in c++ is wrongly set to "variable" instead of "function"

Open VacheDesNeiges opened this issue 1 year ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

When there are more than one scope resolution operator ( "::" ) , if there is a function call at the end of the expression, it will be wrongly categorized as a variable for the syntax tag system used by themes for highlighting the text.

in "std::move()", the word "move" will properly be highlighted as a function.

in "std::chrono::high_resolution_clock::now()", the word "now" will be highlighted by the color set to the tag "variable"

in "std::this_thread::sleep_for(std::chrono::milliseconds(500))", "sleep_for" and "millisecond" will also take the color of the variable tag.

here is a screenshot showcasing this. In the case it is important, the theme used is catppuccin mocha no italic.

image

Environment

Zed: v0.148.1 (Zed) OS: Linux X11 ubuntu 24.04 Memory: 15.5 GiB Architecture: x86_64 GPU: NVIDIA GeForce RTX 4070 || NVIDIA || 535.183.01

If applicable, add mockups / screenshots to help explain present your vision of the feature

Elements ending with parenthesis in an expression with more than one scope resolution operator should have the tag "function" instead of "variable".

I'm not knowledgeable enough in C++ to be certain it would be sufficient to avoid every edge cases, but multiple scope resolution is widely used in the standard library, so qualifying those cases with the tag "function" could be a reasonably better heuristic than the actual tag as "variable".

If applicable, attach your Zed.log file to this issue.

Zed.log

VacheDesNeiges avatar Aug 18 '24 23:08 VacheDesNeiges

Zed uses tree-sitter-cpp for syntax highlighting so this is likely a bug upstream. Can you provide trimmed example of file which includes the different calls so I can easily reproduce?

notpeter avatar Aug 23 '24 15:08 notpeter

Sure, here is a snippet of code sufficient to reproduce this bug.

#include <chrono>
#include <iostream>
void test()
{
    std::chrono::high_resolution_clock::now();
    std::cerr << ":(" << std::endl;
}

I also added a screenshot showcasing how it looks on my side. image

I've been searching information for the last few days and found a few interesting things.

I also didn't see your comment before opening a discussion here when I wanted to share those information.

VacheDesNeiges avatar Aug 23 '24 18:08 VacheDesNeiges