generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Prevent exception if toggling in unsaved file in Reading mode (#…
…1772) * fix: Prevent exception if toggling in unsaved file in Reading mode See the comment #1680 (comment) in #1680. If lines had been deleted from a file, and it was not yet saved when user then toggled a line near the end of the file in Reading mode, there could be an access of a non-existent line number. The resultant output was: plugin:obsidian-tasks-plugin:17605 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'includes') at eval (plugin:obsidian-tasks-plugin:17605:14) at Generator.next (<anonymous>) at fulfilled (plugin:obsidian-tasks-plugin:173:24) * comment: Fix typo
- Loading branch information
1 parent
4ad363b
commit 6332135
Showing
5 changed files
with
134 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...WithTasks_issue 1680 - Cannot read properties of undefined correct behaviour.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Could not find line for task |
1 change: 1 addition & 0 deletions
1
...issue 1680 - Cannot read properties of undefined current incorrect behaviour.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Could not find line for task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
tests/__test_data__/MockDataForTogglingTasks/1680_task_line_number_past_end_of_file.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"taskData": { | ||
"originalMarkdown": "- [ ] #task Section 2/Task 2", | ||
"taskLocation": { | ||
"path": "Manual Testing/Task Toggling Scenarios/1680 - Reading Mode line numbers not updated on editing.md", | ||
"lineNumber": 14, | ||
"sectionStart": 13, | ||
"sectionIndex": 1, | ||
"precedingHeader": null | ||
} | ||
}, | ||
"fileData": { | ||
"fileLines": [ | ||
"## Test Data", | ||
"", | ||
"### Tasks Section 1", | ||
"- [ ] #task Section 1/Task 1", | ||
"- [ ] #task Section 1/Task 2", | ||
"", | ||
"### Tasks Section 2", | ||
"", | ||
"- [ ] #task Section 2/Task 1", | ||
"- [ ] #task Section 2/Task 2", | ||
"" | ||
] | ||
}, | ||
"cacheData": { | ||
"listItemsCache": [ | ||
{ | ||
"position": { | ||
"start": { | ||
"line": 8, | ||
"col": 0, | ||
"offset": 39 | ||
}, | ||
"end": { | ||
"line": 8, | ||
"col": 28, | ||
"offset": 67 | ||
} | ||
}, | ||
"task": " " | ||
}, | ||
{ | ||
"position": { | ||
"start": { | ||
"line": 9, | ||
"col": 0, | ||
"offset": 68 | ||
}, | ||
"end": { | ||
"line": 9, | ||
"col": 28, | ||
"offset": 96 | ||
} | ||
}, | ||
"task": " " | ||
}, | ||
{ | ||
"position": { | ||
"start": { | ||
"line": 13, | ||
"col": 0, | ||
"offset": 119 | ||
}, | ||
"end": { | ||
"line": 13, | ||
"col": 28, | ||
"offset": 147 | ||
} | ||
}, | ||
"task": " " | ||
}, | ||
{ | ||
"position": { | ||
"start": { | ||
"line": 14, | ||
"col": 0, | ||
"offset": 148 | ||
}, | ||
"end": { | ||
"line": 14, | ||
"col": 28, | ||
"offset": 176 | ||
} | ||
}, | ||
"task": " " | ||
} | ||
] | ||
} | ||
} |