summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-06-12 15:18:31 -0400
committerpommicket <pommicket@gmail.com>2025-06-12 15:18:31 -0400
commit59872e535277f59bd8a25deac6f82248b3c7904a (patch)
tree986eca128d3c3996442ecc9f32d32e5b0368b66d
parent828741f64d04cde5cd013597e17e1fcc4c05bc9d (diff)
C# string interpolation, bump version to 2.8.02.8.0
-rw-r--r--README.md1
-rw-r--r--syntax.c51
-rw-r--r--ted.h2
-rw-r--r--windows_installer/ted/ted.vdproj6
4 files changed, 51 insertions, 9 deletions
diff --git a/README.md b/README.md
index d4550e8..3067d9c 100644
--- a/README.md
+++ b/README.md
@@ -362,6 +362,7 @@ Then run `make.bat release`.
<tr><td>2.7.6</td> <td>Fix new LSP bug introduced by 2.7.5</td> <td>2024 Dec 8</td></tr>
<tr><td>2.7.7</td> <td>Add prepareRename support, fix IDE hover</td> <td>2025 Mar 5</td></tr>
<tr><td>2.7.8</td> <td>Fix occasional crash (bad settings pointer)</td> <td>2025 Mar 23</td></tr>
+<tr><td>2.8.0</td> <td>Add syntax highlighting for C#; improvements to other languages</td> <td>2025 Jun 12</td></tr>
</table>
## License
diff --git a/syntax.c b/syntax.c
index 82a7ede..9c6f24d 100644
--- a/syntax.c
+++ b/syntax.c
@@ -79,6 +79,8 @@ enum {
SYNTAX_STATE_CSHARP_STRING_RAW = 0x01,
SYNTAX_STATE_CSHARP_STRING_VERBATIM = 0x02,
SYNTAX_STATE_CSHARP_MULTILINE_COMMENT = 0x04,
+ SYNTAX_STATE_CSHARP_TEMPLATE_STRING = 0x08,
+ SYNTAX_STATE_CSHARP_INTERPOLATING = 0x10,
};
typedef struct {
@@ -2284,8 +2286,10 @@ static void syntax_highlight_gdscript(SyntaxState *state, const char32_t *line,
static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u32 line_len, SyntaxCharType *char_types) {
bool string_is_raw = (*state & SYNTAX_STATE_CSHARP_STRING_RAW) != 0;
bool string_is_verbatim = (*state & SYNTAX_STATE_CSHARP_STRING_VERBATIM) != 0;
+ bool string_is_template = (*state & SYNTAX_STATE_CSHARP_TEMPLATE_STRING) != 0;
bool in_multiline_comment = (*state & SYNTAX_STATE_CSHARP_MULTILINE_COMMENT) != 0;
- bool in_string = string_is_raw || string_is_verbatim;
+ bool interpolating = (*state & SYNTAX_STATE_CSHARP_INTERPOLATING) != 0;
+ bool in_string = (string_is_raw || string_is_verbatim) && !interpolating;
bool in_number = false;
bool in_preprocessor = false;
u32 backslashes = 0;
@@ -2332,7 +2336,15 @@ static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u3
dealt_with = true;
}
break;
- case '"': {
+ case '$':
+ if (line[i+1] == '"') {
+ string_is_template = true;
+ if (char_types) char_types[i] = SYNTAX_STRING;
+ dealt_with = true;
+ }
+ break;
+ case '"':
+ if (interpolating) break;
if (in_string && string_is_raw) {
if (i + 2 < line_len && line[i+1] == '"' && line[i+2] == '"') {
in_string = false;
@@ -2344,6 +2356,7 @@ static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u3
} else if (in_string) {
if (backslashes % 2 == 0 || string_is_verbatim) {
in_string = false;
+ string_is_raw = string_is_verbatim = false;
if (char_types) char_types[i] = SYNTAX_STRING;
dealt_with = true;
}
@@ -2355,7 +2368,33 @@ static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u3
i += 2;
}
}
- } break;
+ break;
+ case '{':
+ if (in_string && string_is_template) {
+ u32 lbraces = 1;
+ if (char_types)
+ char_types[i] = SYNTAX_STRING;
+ for (i++; i < line_len; i++) {
+ if (line[i] != '{') break;
+ if (char_types)
+ char_types[i] = SYNTAX_STRING;
+ lbraces++;
+ }
+ i--;
+ if (lbraces == 1) {
+ // string interpolation
+ interpolating = true;
+ in_string = false;
+ dealt_with = true;
+ }
+ }
+ break;
+ case '}':
+ if (interpolating) {
+ interpolating = false;
+ in_string = true;
+ }
+ break;
case '\'':
if (!in_string) {
if (char_types) char_types[i] = SYNTAX_CHARACTER;
@@ -2404,7 +2443,7 @@ static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u3
char_types[i] = char_types[i+1] = SYNTAX_COMMENT;
}
i++;
- continue;
+ dealt_with = true;
}
}
break;
@@ -2446,9 +2485,11 @@ static void syntax_highlight_csharp(SyntaxState *state, const char32_t *line, u3
}
}
*state = (SyntaxState)(
- (SYNTAX_STATE_CSHARP_STRING_RAW * (in_string && string_is_raw))
+ (SYNTAX_STATE_CSHARP_STRING_RAW * ((in_string || interpolating) && string_is_raw))
| (SYNTAX_STATE_CSHARP_STRING_VERBATIM * (in_string && string_is_verbatim))
| (SYNTAX_STATE_CSHARP_MULTILINE_COMMENT * in_multiline_comment)
+ | (SYNTAX_STATE_CSHARP_TEMPLATE_STRING * ((in_string || interpolating) && string_is_template))
+ | (SYNTAX_STATE_CSHARP_INTERPOLATING * interpolating)
);
}
diff --git a/ted.h b/ted.h
index 7f5f139..a8aab74 100644
--- a/ted.h
+++ b/ted.h
@@ -22,7 +22,7 @@ extern "C" {
#include "command.h"
/// Version number
-#define TED_VERSION "2.7.8"
+#define TED_VERSION "2.8.0"
/// Maximum path size ted handles.
#define TED_PATH_MAX 1024
/// Config filename
diff --git a/windows_installer/ted/ted.vdproj b/windows_installer/ted/ted.vdproj
index 4a0dc56..9ba4d8c 100644
--- a/windows_installer/ted/ted.vdproj
+++ b/windows_installer/ted/ted.vdproj
@@ -620,15 +620,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:ted"
- "ProductCode" = "8:{72C2B66B-B357-435B-9F50-BD23829BB5CE}"
- "PackageCode" = "8:{E505C206-972B-41DD-9DF5-8D295E73C659}"
+ "ProductCode" = "8:{3B295C5E-C63E-4212-BC99-2E58429E1304}"
+ "PackageCode" = "8:{062BC64F-94A7-4DA0-ACAA-E92922554EA4}"
"UpgradeCode" = "8:{844F6C2B-DF3B-4A81-9BD5-603401BBA651}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:FALSE"
"InstallAllUsers" = "11:FALSE"
- "ProductVersion" = "8:25.03.2400"
+ "ProductVersion" = "8:25.06.1200"
"Manufacturer" = "8:ted"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"