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

Bookmarks do not get saved when opening files not belonging to a workspace #595

Open
elesbb opened this issue Mar 9, 2023 · 1 comment

Comments

@elesbb
Copy link

elesbb commented Mar 9, 2023

Hello,

TL;DR: If I don't open the same file in the SAME VS Code window that it was open previously, all bookmarks are lost

I have a text document with notes in, I like to use bookmarks to give me quick ways to navigate to certain things.

If I open the text document using Visual Studio Code, and apply bookmarks, then close the file, and reopen it again (file->open) the bookmarks are gone.

If I open the folder containing the text document as a workspace in Visual Studio Code, then the bookmarks are still there.

If I already have a workspace open, that does NOT contain the text file, open the text file, add bookmarks, close file, reopen file, bookmarks are still there.

If I already have a workspace open, and I do "File: Open Active File in New Window" the bookmarks are gone again.

Is it possible to save ONE location for all bookmarks for all files?? Another option would be each file gets its own file which stores bookmark information in that. When opening a file, extension searches in the "saved_bookmarks" directory for a ".bkms" file. Inside the .bkms file, are the bookmarks which correspond to the (the file currently being loaded/opened.

@elesbb
Copy link
Author

elesbb commented Mar 9, 2023

After looking at the code, I think I see what is happening.

`async function loadWorkspaceState(): Promise {

    // no workspace, load as `undefined` and will always be from `workspaceState`
    if (!vscode.workspace.workspaceFolders) {   **<- This condition is entered, when I opened the file using "File: Open Active File in New Window". It is passed when I open the file inside an instance of VSCode which has a workspaceFolder associated with it.**
        const ctrl = await loadBookmarks(undefined);
        controllers.push(ctrl);
        activeController = ctrl;
        return;
    }`

This is applicable to the save function as well.

Simply adding a setting to always use one location should fix this. So it would look like this:
`async function loadWorkspaceState(): Promise {

    // no workspace, load as `undefined` and will always be from `workspaceState`
    if (!vscode.workspace.workspaceFolders **|| cfg.affectsConfiguration("bookmarks.saveInOneLocation")**) {
        const ctrl = await loadBookmarks(undefined);
        controllers.push(ctrl);
        activeController = ctrl;
        return;
    }`

Make this change in the load and save functions and I think it would work. Then the user can select how/where they want the bookmarks saved. This would be super helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant