Skip to content

[Bug]: Can't delete all contents of a previously-empty git-tracked note when Hunk Signs are enabled #1019

@alythobani

Description

@alythobani

Describe the bug

Obsidian fails to delete all text in a git-tracked note when Hunk Signs are enabled, if the note was empty when last committed to git.

Relevant errors (if available) from notifications or console (CTRL+SHIFT+I)

app.js:1 RangeError: Invalid position 4 in document of length 0
    at e.lineAt (app.js:1:254574)
    at Fh (plugin:obsidian-git:220:243)
    at y0 (plugin:obsidian-git:218:491)
    at Pz (plugin:obsidian-git:220:98)
    at pF (plugin:obsidian-git:220:179)
    at gF (plugin:obsidian-git:227:1462)
    at Rz (plugin:obsidian-git:227:1759)
    at e.update [as updateF] (plugin:obsidian-git:227:469)
    at Object.update (app.js:1:279802)
    at e.computeSlot (app.js:1:290652)

Steps to reproduce

  1. Enable the new Hunk Signs feature
  2. Open a git-tracked empty note (which was an empty note when last committed to the git repo)
  3. Add some text to the empty note, e.g. type in "test", and observe the green hunk sign appear
  4. Try to delete all text in the note (e.g. select all with Cmd + A then hit Backspace)
  5. Close the note then reopen it, and observe that the text was not actually deleted

Expected Behavior

It's possible to delete all content in the note

Addition context

Screen.Recording.2026-01-21.at.10.20.41.AM.mov

^ Side note: some other logs from the obsidian-git plugin are extremely frequent and clutter up the dev tools console, and could be worth removing. But that's a much smaller issue obviously

Also I mentioned this in the Discord, but I'll say it again here, the Hunk Signs feature is awesome, massively appreciate it!! This bug is the only significant issue I've faced with it so far, and does lead me to frequently toggle Hunk Signs on and off to work around it.

Operating system

macOS

Installation Method

None

Plugin version

2.36.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions