Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.21k stars 258 forks source link

[Bug]: There is a bug in the ”discard“ feature. #734

Open fantab01 opened 1 month ago

fantab01 commented 1 month ago

Describe the bug

Describe

When a complex md file uses the discard function, it will show that the file has been changed when switching to reading mode, but when clicking the diff view, it will show that there is no difference.(The gif is recorded in a sandbox environment. The only change to the sandbox environment is to install the git plugin.)

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

SYSTEM INFO:
    Obsidian version: v1.6.3
    Installer version: v1.5.12
    Operating system: Windows 10 Pro 10.0.19045
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Base theme: adapt to system
    Community theme: none
    Snippets enabled: 0
    Restricted mode: off
    Plugins installed: 1
    Plugins enabled: 1
        1: Git v2.24.2

RECOMMENDATIONS:
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Steps to reproduce

Special notes for reproducing bugs.md bug

Expected Behavior

Switching to reading mode shouldn't change the file, right? I'm curious about the cause of this bug.

Addition context

No response

Operating system

Windows

Installation Method

None

Plugin version

v2.24.2

Vinzent03 commented 1 month ago

Please execute the git diff <path to your file> command in the terminal to see the actual diff. But I agree that switching to reading more shouldn't change the file itself.

fantab01 commented 1 month ago

Please execute the git diff <path to your file> command in the terminal to see the actual diff. But I agree that switching to reading more shouldn't change the file itself.

Thank you for your advice, it’s very useful. This is another classic line ending issue. I have temporarily solved it by using git config core.autocrlf true. However, I am curious as to why switching to reading mode triggers the plugin's diff changes, and how you plan to resolve it. This situation can indeed cause confusion. image

Vinzent03 commented 1 month ago

This plugin doesn't touch your file when switching to reading mode, that has to be Obsidian. I think the plugin is working mostly correctly. The only issue is that the diff view doesn't show that the line endings have changed, but from what I know that's typical for diff views.