Sublime Forum

; in string and NS messes up syntax highlighting for C++

#1

The text below in a cpp file
makes everything after the row starting with NS_LOG look and act (no symbols can be found) like a comment.
I tried this on the latest Sublime 3 portable download: “Sublime Text Build 3047.zip”
So it was reproduced in the clean download.
The problem also exists in Sublime 2

The funny thing is that just changing the first char in “NS_LOG” makes it work. Unfortunately all our log macros start with NS…

#include “stdafx.h”

int _tmain(int argc, _TCHAR* argv])
{
int test = 11;
PS_LOG("NewPolltime: " << GetPath(vh) << "; ms: " << ms << ", oldindex: " << oldIndex << ", index: " << index << “; server” << m_rs.GetServerName().AsString());
int test2 = 22;
NS_LOG("NewPolltime: " << GetPath(vh) << "; ms: " << ms << ", oldindex: " << oldIndex << ", index: " << index << “; server” << m_rs.GetServerName().AsString());
int messed_up = 33;
return 0;
}

0 Likes

#2

Fixed by changeing row 536 in C.tmLanguage inside Packages\C++.sublime-package
This is must come from some old Next/objective C special case…

from
(?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s*()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]+\b | :: )++ # actual name
to
(?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate)\s
()(?:[A-Za-z_][A-Za-z0-9_]*+\b | :: )++ # actual name

0 Likes