GithubHelp home page GithubHelp logo

Comments (3)

deviant avatar deviant commented on September 26, 2024 1

I am running into this also. I'm using Syncthing to access my Logseq graph across multiple computers, which is the main place where I experience this issue, but occasionally get tripped up when editing pages in a text editor as well. I'm currently working around this by obsessively exiting editing mode every time I switch away from Logseq, leave a computer, lock my phone, switch between devices, etc. While this works, this is obviously annoying and unpleasant to do, and there's still a risk if I forget (for whatever reason).

The bug does actually affect all pages, not just the journal— it's just much easier to trigger via the journal. Part of this is because Logseq enters editing mode when opening new pages, which happens automatically for each new day while viewing the journal. Also, since it only occurs when the currently edited line changes, it's more likely to happen when you keep a blank line at the end of the page, ready for input (as I do)— this makes sense to do in the journal, but less-so in regular pages.

It's also not quite accurate to say that the data is "lost", although it is without intervention. The line currently being edited can be restored by using the Undo command. It seems to me as though Logseq implements reloading of files by reading in their contents, positioning the cursor on the line it was previously at, and then overwriting the line with the previous contents of that line prior to the reload.

This behaviour definitely seems suboptimal. Instead I think Logseq should be diffing the two versions of the file to find the new location of the currently edited line and its surrounding context, and reposition the cursor there instead. If it can't find either of these, it should just fall back to creating a new line at the end of the file. If it can, and the currently edited line has only changed partially, it's probably sensible to just use the version from the file, rather than duplicating it. (I'm unsure whether it's better to keep the cursor at the same column, or move it to the end of the line, but plausibly the latter). If there is common context, but the currently edited line is not present, and there are new lines in the file where it's supposed to be, it should probably be moved after the last of these new lines— but only after ones that are at or below its current indent level, to preserve semantics as best as possible.

I hope the description of this logic isn't too difficult to understand! There are quite a few points that need to be given consideration in order to have a (relatively) seamless experience here.

As an aside, the snapshots in logseq/bak offer another way to retrieve the missing data, if you're not too slow about it, but it might not be in there if you're unlucky.

While debugging this, I also managed to run into a bug where the backing file and its state in Logseq could become permanently diverged (not fixable with a regular graph refresh, requiring a full re-index to remedy). I'm not sure what the exact steps were, but it involved going back and forth between editing a page in Logseq and a text editor, and Undo/Redo in Logseq. Possibly a race condition. After this was triggered, edits to the backing file would no longer end up in Logseq, and Logseq stopped saving its state to disk. This persisted through restarts. Unsure if this is relevant to the current issue, but figured I'd include it just in case.

from logseq.

MarSik avatar MarSik commented on September 26, 2024

I am seeing the same behavior. My second computer lost the first entry from each day this way.

from logseq.

e-zz avatar e-zz commented on September 26, 2024

This is common when you have two different devices running Logseq all the day.
Logseq automatically jumps to the next day's jornal page when the day changes, and enter editing mode in the first block. So if you have one remote device also running Logseq, basically it means you have a remote client always editing the first block. That's why it happens.

One workaround is to close Logseq on your machine when you leave it. Another is when you come back to the remote machine, which is editing the first block, press Esc to exit editing mode without editing. Then it should be fine.

But I still hope Logseq devs can provide a way to turn it off. This behavior is indeed sometimes annoying.

from logseq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.