Skip to content

Commit

Permalink
Treat predefined_type as an atom in TypeScript
Browse files Browse the repository at this point in the history
Currently it contains a nested string node, even though it's a fixed
set of known types. This was preventing us from applying good syntax
highlighting.

This was particularly noticeable with `string`, which wasn't
previously highlighted as a type.
  • Loading branch information
Wilfred committed Jan 8, 2023
1 parent 610a6e4 commit 34967f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ constituents.
Fixed an issue with unwanted underlines with textual diffing when
DFT_GRAPH_LIMIT is reached.

Improved syntax highlighintg for predefined types in TypeScript.

## 0.40 (released 28th December 2022)

### Diffing
Expand Down
3 changes: 3 additions & 0 deletions sample_files/compare.expected
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ b142169ae6ac08ef64d0cf67a2e66f5b -
sample_files/toml_before.toml sample_files/toml_after.toml
08dad07d7c85b807094b5b4cf065cda9 -

sample_files/typescript_before.ts sample_files/typescript_after.ts
06648ebbe63a69e29de54b541fa2b3b8 -

sample_files/typing_before.ml sample_files/typing_after.ml
544c31c1d6651437ba9ed3a3a3524d76 -

Expand Down
5 changes: 5 additions & 0 deletions sample_files/typescript_after.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Symbol = {
kind: "symbol";
name: string;
items: string[];
};
4 changes: 4 additions & 0 deletions sample_files/typescript_before.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type Symbol = {
kind: "symbol";
items: string[];
};
2 changes: 1 addition & 1 deletion src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ pub fn from_language(language: guess::Language) -> TreeSitterConfig {
let language = unsafe { tree_sitter_typescript() };
TreeSitterConfig {
language,
atom_nodes: vec!["string", "template_string", "regex"]
atom_nodes: vec!["string", "template_string", "regex", "predefined_type"]
.into_iter()
.collect(),
delimiter_tokens: vec![("{", "}"), ("(", ")"), ("[", "]"), ("<", ">")],
Expand Down

0 comments on commit 34967f5

Please sign in to comment.