Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent exception if toggling in unsaved file in Reading mode #1772

Merged
merged 2 commits into from
Mar 20, 2023

Conversation

claremacrae
Copy link
Collaborator

Description

This prevents an exception if toggling in unsaved file in Reading mode.

See the comment #1680 (comment).

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)

Motivation and Context

Another step in fixing outlier conditions in toggling tasks in Reading view

How has this been tested?

By adding a test which showed the problem behaviour, before the fix was applied.

Screenshots (if appropriate)

Types of changes

Changes visible to users:

  • Bug fix (prefix: fix - non-breaking change which fixes an issue)

Internal changes:

  • Tests (prefix: test - additions and improvements to unit tests and the smoke tests)

Checklist

Terms

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)
@claremacrae claremacrae added the scope: data integrity Problems that may cause loss or corruption of user data label Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: data integrity Problems that may cause loss or corruption of user data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant