Skip to content

Commit 9288365

Browse files
committed
test: Show that 'Simple Tab Indent' plugin breaks task reading
https://github.com/hoomersinpsom/simple-tab-indent
1 parent 5088c2a commit 9288365

File tree

4 files changed

+182
-0
lines changed

4 files changed

+182
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# zero_width
2+
3+
- Root 1
4+
- [ ] #task Task line 1 in 'zero_width' - indented by tab character
5+
- Root 2
6+
​ - [ ] #task Task line 2 in 'zero_width' - indented by ZWSP + tab character
7+
8+
```tasks
9+
path includes {{query.file.path}}
10+
```

tests/Obsidian/AllCacheSampleData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import yaml_tags_with_one_value_on_new_line from './__test_data__/yaml_tags_with
8181
import yaml_tags_with_one_value_on_single_line from './__test_data__/yaml_tags_with_one_value_on_single_line.json';
8282
import yaml_tags_with_two_values_on_one_line from './__test_data__/yaml_tags_with_two_values_on_one_line.json';
8383
import yaml_tags_with_two_values_on_two_lines from './__test_data__/yaml_tags_with_two_values_on_two_lines.json';
84+
import zero_width from './__test_data__/zero_width.json';
8485

8586
/**
8687
* All the sample data in `resources/sample_vaults/Tasks-Demo/Test Data`.
@@ -171,5 +172,6 @@ export function allCacheSampleData(): SimulatedFile[] {
171172
yaml_tags_with_one_value_on_single_line,
172173
yaml_tags_with_two_values_on_one_line,
173174
yaml_tags_with_two_values_on_two_lines,
175+
zero_width,
174176
];
175177
}

tests/Obsidian/FileParser.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readTasksFromSimulatedFile } from './SimulatedFile';
22
import multiple_headings from './__test_data__/multiple_headings.json';
3+
import zero_width from './__test_data__/zero_width.json';
34

45
describe('FileParser', () => {
56
it('should set all non-TasksFile data in TaskLocation', () => {
@@ -44,4 +45,17 @@ describe('FileParser', () => {
4445
]
4546
`);
4647
});
48+
49+
it('does not read task lines beginning with a ZWSP - zero-width space', () => {
50+
// Demo the behaviour of Obsidian when then Simple Tab Indent plugin indents what looks like a task line.
51+
// https://github.com/hoomersinpsom/simple-tab-indent
52+
const data = zero_width;
53+
expect(data.fileContents).toContain("- [ ] #task Task line 1 in 'zero_width' - indented by tab character");
54+
expect(data.fileContents).toContain(
55+
"- [ ] #task Task line 2 in 'zero_width' - indented by ZWSP + tab character",
56+
);
57+
const tasks = readTasksFromSimulatedFile(data);
58+
expect(tasks.length).toEqual(1);
59+
expect(tasks[0].description).toEqual("#task Task line 1 in 'zero_width' - indented by tab character");
60+
});
4761
});
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"cachedMetadata": {
3+
"headings": [
4+
{
5+
"heading": "zero_width",
6+
"level": 1,
7+
"position": {
8+
"end": {
9+
"col": 12,
10+
"line": 0,
11+
"offset": 12
12+
},
13+
"start": {
14+
"col": 0,
15+
"line": 0,
16+
"offset": 0
17+
}
18+
}
19+
}
20+
],
21+
"listItems": [
22+
{
23+
"parent": -2,
24+
"position": {
25+
"end": {
26+
"col": 8,
27+
"line": 2,
28+
"offset": 22
29+
},
30+
"start": {
31+
"col": 0,
32+
"line": 2,
33+
"offset": 14
34+
}
35+
}
36+
},
37+
{
38+
"parent": 2,
39+
"position": {
40+
"end": {
41+
"col": 68,
42+
"line": 3,
43+
"offset": 91
44+
},
45+
"start": {
46+
"col": 1,
47+
"line": 3,
48+
"offset": 24
49+
}
50+
},
51+
"task": " "
52+
},
53+
{
54+
"parent": -2,
55+
"position": {
56+
"end": {
57+
"col": 76,
58+
"line": 5,
59+
"offset": 177
60+
},
61+
"start": {
62+
"col": 0,
63+
"line": 4,
64+
"offset": 92
65+
}
66+
}
67+
}
68+
],
69+
"sections": [
70+
{
71+
"position": {
72+
"end": {
73+
"col": 12,
74+
"line": 0,
75+
"offset": 12
76+
},
77+
"start": {
78+
"col": 0,
79+
"line": 0,
80+
"offset": 0
81+
}
82+
},
83+
"type": "heading"
84+
},
85+
{
86+
"position": {
87+
"end": {
88+
"col": 76,
89+
"line": 5,
90+
"offset": 177
91+
},
92+
"start": {
93+
"col": 0,
94+
"line": 2,
95+
"offset": 14
96+
}
97+
},
98+
"type": "list"
99+
},
100+
{
101+
"position": {
102+
"end": {
103+
"col": 3,
104+
"line": 9,
105+
"offset": 225
106+
},
107+
"start": {
108+
"col": 0,
109+
"line": 7,
110+
"offset": 179
111+
}
112+
},
113+
"type": "code"
114+
}
115+
],
116+
"tags": [
117+
{
118+
"position": {
119+
"end": {
120+
"col": 12,
121+
"line": 3,
122+
"offset": 35
123+
},
124+
"start": {
125+
"col": 7,
126+
"line": 3,
127+
"offset": 30
128+
}
129+
},
130+
"tag": "#task"
131+
},
132+
{
133+
"position": {
134+
"end": {
135+
"col": 13,
136+
"line": 5,
137+
"offset": 114
138+
},
139+
"start": {
140+
"col": 8,
141+
"line": 5,
142+
"offset": 109
143+
}
144+
},
145+
"tag": "#task"
146+
}
147+
]
148+
},
149+
"fileContents": "# zero_width\n\n- Root 1\n\t- [ ] #task Task line 1 in 'zero_width' - indented by tab character\n- Root 2\n\t- [ ] #task Task line 2 in 'zero_width' - indented by ZWSP + tab character\n\n```tasks\npath includes {{query.file.path}}\n```\n",
150+
"filePath": "Test Data/zero_width.md",
151+
"getAllTags": [
152+
"#task",
153+
"#task"
154+
],
155+
"parseFrontMatterTags": null
156+
}

0 commit comments

Comments
 (0)