Giter VIP home page Giter VIP logo

obsidian-remember-cursor-position's Introduction

Remember cursor position

This plugin for Obsidian remembers the cursor position and scroll for each note. This is very convenient when you switch between notes, go from link to link, go back, you do not need to scroll to the place where you were the last time.

The cursor position, scrolling and text selection for all notes are stored in a file (the path can be set in the settings), so everything is restored even if you close Obsidian and open it again.

It works in edit and preview mode.

obsidian-remember-cursor-position's People

Contributors

despin avatar dy-sh avatar mikkovedru avatar stefandanzl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-remember-cursor-position's Issues

Getting constant merge conflicts from obsidian-git

I use obsidian-git to sync my vault with other machines, and it gets stuck whenever there is a merge conflict. .obsidian/plugins/remember-cursor-position/cursor-positions.json is a constant source of merge conflicts, because its json data is all stored in one line, which git doesn't automatically deal with.

Feature Request:

Could you add the option to pretty print this json file?
Preferably, the keys ought to get sorted, and each line should contain at most one key+value pair.

Cursor repositions when note is back in focus and I want to type

Also since the last update, this has been happening.

If I am in a different tab and come back to the previous note and want to start typing, for roughly two seconds I cannot do so. As I hit the first key, the cursor shifts back and it does that unless I wait and start typing when the offending time period lasts.
This is especially annoying when my other tab is a video and I take notes on it or when juggling different tabs in a normal worfklow.

[Feature Request] Drop out of range date

I would like to have a feature to discard cursor positions that were remembered beyond a certain date range,

for example, older than [30/7/3/1] days. This way, I can delete the cursor positions that were saved a long time ago and avoid opening cursor positions from too far back in time.

Not working after update to 1.4.5

After automatic update to Obsidian Windows Version 1.4.5 on Win10 the cursor position is not saved anymore. The last changed date of the cursor-positions.json file was yesterday.

Not working on Android

File is correctly updated with cursor position however it does not scroll to position after closing the file or exiting obsidian. Tested in source view and live view.

Obsidian 1.4.9
Android 13, pixel 6a

Aberrations in the behavior of the Sliding Panes plugin

Causes aberrations in the behavior of Sliding Panes using the Ars Magna theme. When 'Toggle stacking' is enabled (i.e., note panels stacked to the left and right) some notes are locked and clicking on them does not cause them to unfold.

It seemed strange to me, but this aberration occurs especially with the notes corresponding to templates (in the default templates folder of the core plugin).

Does not remember cursor position

This plugin has been working amazingly until about a week ago. Now it does not seem to record the current position anymore? I tried even on a blank vault with no other plugins installed. I see cursor-positions.json is being updated, but all the positions are 0

{"Doc A.md":{"scroll":null},"Doc B.md":{"scroll":0,"cursor":{"from":{"ch":0,"line":0},"to":{"ch":0,"line":0}}}}

Twitching behaviour since last update

I was going to make a gif on this happening but when I prepared my ShareX program last time around, I was not able to reproduce.

The twitching between two cursor positions lasts for 6-10 jumps then ceases.

  • Comment: this is not the same lag behaviour as it happens in a very long note.

[Linux, Windows]

卡顿问题

打开插件之后切换文件页面会卡顿是什么情况?

Cursor position persists when heading level target is initiated

Not sure since when this is happening.
Have heading level targets ever been prioritized? I seem to remember no issues in the past.

When I am saved with cursor position X in file 'Abc' and I click on [[Abc#Def]] from file 'Xyz', I would like cursor position X superseded.

Thanks

[Feature Request] Flash active line once cursor position set

I find it hard to spot the cursor location when opening documents and would really benefit from a visual indicator of where find it.

As such, I propose the idea of flashing the entire line over a configurable duration (milliseconds) once the cursor has been positioned to draw the eye to it.

The active line can be easily located by the following class :

<div class="cm-active cm-line">

Hope that makes sense and is something that you see adding value. Until then, I am tweeking the CSS to simply add an indicator on the right hand side of the current line to make it easier for me to locate it without it getting in the way all the time.

Thanks in advance.

Conflict when clicking a header or block link

For instance, there can be some conflicts in the following use case:

  • First, I edit something in Note A, the cursor position would be remembered, which is the desired behaviour.
  • Next, in Note B, there is a link that goes to a specific header/block in Note A.
  • When I click the link from within Note B, the desired behaviour might be to go to the header/block. However, with this plugin enabled, it would go to the last cursor location in Note A.

On the other hand, if the link in Note B does not go to a specific header or location, then it would be totally fine to go to the remembered cursor location.

Path issue on Linux (and probably Mac too) when first installed

Hi, thank you for this extension, it will be very helpful when working on long documents!

When I first installed the extension it was dumping the save file right into the root folder of my vault with a very long filename. I realized that this is happening because in the plugin settings, the default filename is something like:

.obsidian\plugins\obsidian-remember-cursor-position\cursor-positions.json

This probably works fine on Windows, but Linux and Mac systems use a / rather than a \ as a directory separator. Therefore the cursor position gets saved in a file in the root directory of the vault that's named something like .obsidian\plugins\obsidian-remember-cursor-position\cursor-positions.json. (there was another file in there too that was the same name but with the backslashes url-encoded, but I don't know if that was because of the plugin or my use of Dropbox or something)

Changing all the backslashes to forward slashes in the plugin's settings makes it stash the file in the obsidian/plugins/[...] subfolder as expected (and then the oddly-named file in the root of the vault can be deleted)

Obviously this is not a huge issue, and the plugin itself still works, but it would be nicer if it saved correctly on Linux and Mac systems.

Thank you again for the plugin!

Запрос функции самостоятельного указания положения курсора для отдельных заметок, и горячей клавиши для перемещения по таким позициям

Приветствую, я снова к Вам с запросами :)
Нельзя ли сделать так, чтобы была возможность вручную проставлять в тексте какой-то маркер, куда именно курсор должен вернуться при следующем открытии той или иной заметки. Либо даже несколько маркеров, чтобы, при открытии заметки курсор устанавливался на первый из них, и была бы возможность прыгать по другим позициям вверх-вниз, используя горячие клавиши. А в заметках, где нет такого маркера, чтобы сохранялась работоспособность основного функционала плагина.
Это позволило бы вручную задавать позицию, с которой хотелось бы продолжить редактирование в следующий раз, при открытии заметки после длительного промежутка времени.
Это может быть полезно, например, для заметок с длинным блоком YAML, чтобы при открытии заметки в режиме редактирования, этот блок сразу бы прокручивался, и верхней строкой становилась та, в которой проставлен идентификатор положения курсора, например, строка с первым заголовком первого уровня. Это помогло бы многим пользователям forum.obsidian.md, из таких тем, как: Can you hide the “Metadata” box when previewing a note with YAML metadata?; YAML YAML, Go Away; Hiding YAML in Edit Mode; Option to hide frontmatter in live preview; Save reading position; When opening document place the cursor at the bottom of it.

Doesn't work when clicking a task in a Dataview list and going to file

I have a dataview query that shows all open tasks from a file. When I click the task in this dataview part, the relevant file opens in Obsidian. Instead of taking me to the task I clicked on, this plugin activates and then takes me to the last cursor position. I have set the delay setting to the maximum, and it does not help.

A potential solution would be to have an option to "exclude" certain folders or files (ideally the latter in my case, but could work either way) from having their cursor position remembered. However, the best solution would be for the plugin to recognise that a dataview item was clicked and then not interfere with the cursor position.

Here is the dataview query that I am using:

TASK FROM "0. Inbox/0. Roaming"
WHERE !completed

[Feature Request] Remember Cursor Position ONLY FOR Specific Notes

Hello @derwish-pro !

First of all, thank you so much for this plug-in. It fills a gap in Obsidian that is extremely important to my workflow.

I'd like to make a feature related to my workflow:

Create an option to let the user define which notes will be affected by the remember cursor plug-in:

  • I only want to remember the cursor position to a subset of notes in my vault. Specially, the notes related to my reading and writing workflow.
  • In some cases, after finishing to read/write long texts, it's not necessary anymote to remember the cursor position.

As far as I know, there is two ways to do this:

1. YAML

Uses YAML to toggle/activate Remember Cursor Position ON to Specific Notes.

2. Plug-in Settings

Create an option on plug-ins settings to let the user choose which notes will be "remembered".

Inspiration/Information: The plug-in "Hotkeys for Specific Files" found out a way to select notes from the vault and apply some behavior (in his case, to create hotkeys to specific notes)

Screen Shot 2021-07-07 at 10 11 27
Screen Shot 2021-07-07 at 10 11 59

I hope you like my suggestion! Let me know if you need more information.

Thanks and have a great day!

Doesn't work from recent files

If I switch between files manually, the cursor position is saved, this is fine!
But if I use "recent files" plugin to switch between files, and most of the time I use exactly it, - it doesn't work, cursor is at the beginning, not last position...

can it be fixed?

[Feature Request] Remember cursor position on same page

Thank you so much for your plugin! Remembering the cursor position while moving through notes is really important, I think.

Feature request: also remember cursor position when navigating on the same page.

Scenario: a note with multiple headings, with a table of contents at the top of the note, linking to the headers below. If I click on such a link in the TOC, Obsidian goes to the header and highlights it. If I go back, though, Obsidian takes me to the previous note (and there to the remembered cursor position, with your plugin activated). Better would be to be able to jump back to the TOC in view, then branching down to another heading, back to the TOC etc. This would also mimic the way a browser works.

Any chance to implement this additional mode of remembering the cursor position in your plugin? That would be wonderful.

Cursor jumps from where I clicked in an inactive pane to the remembered position

Suppose I have panes A and B open. A is active and I click somewhere in B. Pane B becomes active and the cursor blinks once where I clicked, I start typing expecting my text to appear there, but between first and second blink the plugin moves the cursor to the remembered position and my newly typed text appears there. This keeps happening to me even when delay is set to 0ms and it is very annoying. The only difference 0ms makes is that the first blink ends faster than normal and you can tell something odd is happening.

The first blink where I clicked should not be visible or, better, the cursor should stay where I just clicked and the plugin should forget the remembered position. Intuitively, when a pane is already open and you click in a certain place, you would expect the cursor to move there.

插件无法生效

在更新Obsidian 1.4.5后,Obsidian更新了对文件的properties的渲染,这对此插件的运行造成了冲突,无法保存当前文件的光标位置。
每次打开新的文件时,光标总是在properties的下一行。
返回之前的文件时,光标也是在properties的下一行,无法跳转到之前的为止。

配置是下图时,插件没有生效
image

配置是下图时,插件才能生效
image

Feature request: don't scroll if the document was changed by clicking (or by following the link)

If I go to the note via keyboard:

  • search
  • changing tabs
  • going/clicking on the link
    , I want the cursor position to be remembered and restored.

But this is an undesirable behavior when I operate with several tabs and use the mouse to change the active tab. I that case I don't simply click somewhere on the desired tab, but try to hit the mouse somewhere where I want my cursor to be. Unfortunately, this plugin takes that cursor position and changes it to the old one. Would be nice to have the ability to disable this behavior.

Thank you @derwish-pro for you plugin!

Position loose when editing list

The position always lose after I modified list, not everytime but most of the time after swifting preview mode and editing model, cursor position return to the top of the note.

Feature request: Remember horizontal scroll position for each note

Thank you for this useful plugin @derwish-pro. I was wondering if the plugin could also be made to remember the horizontal scroll position for each note in addition to the vertical scroll position. I've tested it out, and at the moment, it only remembers the vertical scroll position.

Unusually High StartUp Time

Using the "Debug StartUp Time" toggle, I noticed that every time I startup Obsidian, remember Cursor Position takes up the highest amount of ms for starting up out of all plugins I have installed (~50 plugins).

Remember Cursor Position takes up ~150ms; in comparison: dataview, one of the most resource intensive plugins, only requires 50ms on my machine.

I investigated a bit and it seems reading the remembered cursor positions is the culprit, deleting the respective json reduced to startup time of the plugin to nearly 0ms again.

Invalid after Obsidian restart

The cursor cannot locate the historical position from the last exit

The investigation revealed that:「cursor-positions.json」file size is 0 kb

Prove that some kind of error occurred during writing. (Because the file modification time has changed)

Furthermore,occasionally valid when I delete 「data.json」 files,and then 「cursor-positions.json」file size is about 1 kb

Most of the time it doesn't work

[FR]: Add command to go back and forth like VSCode

##My idea
It would be fantastic if remember cursor position plugin allows users to go back and forth between cursor positions within same file and even different files. It's just like VSCode. It may be more complicated. I hope this would be added in roadmap.

Thanks a lot for your work! 😄

Remember if in edit or preview mode too

Hi, this is a great plugin - thanks! Could it be extended to remember if I was in edit or preview mode when last in the note, then restore the previous mode for the note?

When same document is opened in multiple tabs and one tab is hidden, the other tab tries to restore the hidden tab scrolling position

So multi-tab of same document support is quite good when all the tabs are visible on different panes, but say I have multiple tabs on some of my panes like this:

  • Left pane: document A (visible)
  • Right pane: document A, document B (visible)
    When I switch focus form Right to Left pane, the document A on the right will auto-scroll to the last position on the hidden document A from the Right pane.

Repro:

  1. Create 2 dummy files A and B
  2. Open tabs following this config:
  • Left pane: document A (visible)
  • Right pane: document A (visible), document B
  1. In left pane doc A, scroll down to position X (you can keep it at the top)
  2. In right pane doc A, scroll down to position Y (you can also select some text to make the bug more obvious)
  3. In right pane, click on doc B to hide doc A. You now see A on the left at pos X, B on the right. Make sure right pane doc B is focused.
  4. Focus left pane
    Expected: left pane doc A preserves scrolling position X
    Actual: left pane doc A scrolls to position Y (and highlights text if we selected some in step 4)

As a comparison I tried https://github.com/ludovicchabant/obsidian-remember-file-state which used not to support multi-tabs well, but it now supports them including hidden tabs properly.

Please disable, when having documents already open and working with two or more panes

I love this feature when I open documents.
But when working with two or more open files, clicking, dragging/dropping, this becomes horrible.

I click on a part on my open right window - a short moment later my courser jumps.
I click on the left again - my courser jumps.

I want my location remembered, when I open my document, not while I have it open working on it.
This is something Obsidian already does on its own, not interfering with clicking on certain parts :)

Obsidian 1.x: causes the entire page to shift up sometimes

When you switch tabs, some notes and cursor positions make the entire page shift up. So the top is cut off so you can't even see the tabs anymore:
screenshot 2023-01-04T155418Z

And you end up with this weird gray area at the bottom:
screenshot 2023-01-04T155331Z

I think it's because this plugin causes an abnormal scroll event on the wrong div. This didn't happen before Obsidian 1.x. So it must have to do with the new tabbed layout or something.

Only some tabs get displayed like that (I can't seem to figure out the pattern of documents and cursor positions yet).

Wrong cursor position when using Ozan's Image in Editor Plug-in

Hi!
Thank you for your work, it is an excellent addition to Obsidian.

Just to inform you that, when you enable the Ozan's Image in Editor plug-in (https://github.com/ozntel/oz-image-in-editor-obsidian), cursor position seems to not to be calculated properly. It seems that your plug-in is not taking into consideration the images, and placing the cursor in a wrong place when you re-open the note as a result. This is happening only when you have images or documents in the note. If the note is text-only, your plug-in is working nice.

Regards, K.

The plugin prevents follow the backlink standart obsidian behaviour

Steps to reproduce:

  1. Open some note with backlinks.
  2. Click on backlink.

Best if the backlinked note is long enough to span multiple screens. Last cursor position in backlinked note should be near end of file. The link from the "backlinked note" to the "some note" should be in the middle of the note.

Expected Behavior:

  1. Obsidian opens backlink-note, scroll down to the corresponding link and highlight it.

Actual behaviour:

  1. Obsidian opens backlink-note, scroll down to the corresponding link and highlight it.
  2. Cursor moves down to the last position, so highlighted corresponding link fly-away upper.

not working anymore now in Obsidian 0.15.9

It used to work as expected a few weeks/months ago, but currently is not working anymore... When I switch between files, the cursor stays at the beginning of each file. I have tried disabling/ enabling the plugin, uninstalling/reinstalling it, and changing the plugin setting (the json file path and delay in ms). Neither of them worked for me. Since the last time it worked properly, I haven't changed anything (modifying settings, installing new plugins, ...etc.) except updating Obsidian itself and other plugins to-date. Now I have Obsidian v0.15.9.

I am not sure whether it's a bug of this plugin. Is there anyone else who has the same issue? I would really appreciate it if you could take time to check out and fix it. Thank you so much for bringing such useful plugin to us!

Doesn't work with "Obsidian tabs" plugin

Hi, I always have a number of notes open using the tabs plug-in. When I move between 2 open notes in Edit it does not remember the cursor position, nor when I move between notes in Preview, nor between a note in Edit and one in Preview.

I am on MacOS.

support live preview

if It works in live preview mode , i close Obsidian and open it again,it cannot remember

Does not work with "go back"

Open document A
Open document B (on top of A)
Click "go back" - cursor is lost, or actually at top of document, though scroll

Wish it worked as well as switching between documents using Ctrl+O.

[Feature Request]Custom delay time

At present, the maximum delay time that can be selected is only 300ms. When I use Sliding Panes, there will always be some problems. I hope I can customize the delay time

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.