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 removed if file closed? #23

Open
NeQuissimus opened this issue Apr 17, 2014 · 14 comments
Open

Bookmarks removed if file closed? #23

NeQuissimus opened this issue Apr 17, 2014 · 14 comments

Comments

@NeQuissimus
Copy link

I have an issue where a bookmark is removed once I use it.

My setup:
Sublime Text 3 build 3061
OSX 10.9.2

Steps to reproduce:

  • Open a file
  • Set a bookmark for a line
  • Close the file (close the tab)
  • Open Command Palette and select "SublimeBookmarks: Goto Bookmark"
  • Select bookmark that was just created (Note that at this point the bookmark is no longer marked as such)
  • Close the tab again
  • Open Command Palette and try selecting the bookmark again and it will not be there anymore

Sublime Text Console:

add
[<Sublime Bookmarks.bookmark.Bookmark object at 0x11010edd0>]
EMPTY BOOKMARK. NAME: Bookmark1
[]

It seems to me that the bookmark is removed from the list once I have used it.
I tried going through the plugin code but I could not see anything obviously wrong.

Also, I am not sure this is intended behaviour (this does not happen if you keep the tab open!) or not.

@anandsunku
Copy link

yes i too tried the same, open the project, add a bookmark, close the tabs, exit sublime, open the project, cmd+p, gotobookmark, there are no bookmarks

@NeQuissimus
Copy link
Author

@anandsunku That sounds like slightly different behaviour

Here is what I have been able to find out:
When closing the tab and then hitting "Goto", the file is re-opened but none of the bookmarks for said file are highlighted. It seems that they are all considered empty, and therefore removed from the list of valid bookmarks.

@cornelius-k
Copy link

I'm having the same issue, are you never supposed to close your files? I was hoping that bookmarks would get saved to the project.

@inigopascall
Copy link

I am also having the same issue; closing files seems to be liable to erasing all bookmarks. Seems to happen intermittently but often enough to make this plugin unusable. It would be great it this problem could be fixed, because this is potentially a very useful plugin.

@ghost
Copy link

ghost commented Apr 1, 2015

When you select the bookmark after closing the tab, it is probably showing a cached entry which is refreshed when you open the file, and the plugin finds no bookmarks and if you try the gotobookmark with the file opened the second time it should show no bookmarks. So the bookmarks are not being saved here or are failing to get saved or something.

it is indeed a quite useless plugin if bookmarks are not saved between files open/close because then they are not really bookmarks!
It is probably dued to the project feature that was added in jan14? I don't know.

@kannus
Copy link

kannus commented Nov 2, 2015

I encountered the same problem and decided to debug further since it's such a useful package for day-to-day task. If my understanding is correct, the problem seems to be that the bookmark was "updated" while the view was still loading and thus deemed "empty" and removed.

Changing one line is sublimebookmark.py seems to do the trick (by ignoring the bookmark when the view is still loading, since the same function will be called again later on via other event, but I can't say this is definitely the right solution):

# 1. move bookmarks
# 2. update their regions when text is entered into the buffer
def _UpdateBookmarkPosition(self):
    # this bookmark (might) have been changed
    # since it's in the current file
    # We're on a thread anyway so update it.
    for bookmark in BOOKMARKS:

        # if the activeView is the bookmark's view, update r
        #if bookmark.isMyView(self.window, self.activeView):
        if bookmark.isMyView(self.window, self.activeView) and not self.activeView.is_loading():

            bookmark.updateData(self.window, self.activeView)

            # the bookmark is empty - it has no data in it.
            if bookmark.isEmpty(self.activeView):
                Log("EMPTY BOOKMARK. NAME: " + bookmark.getName())
                removeBookmark(bookmark)

@HuangLK
Copy link

HuangLK commented Mar 6, 2016

@kannus it works!

@inigopascall
Copy link

@kannus Sorry, where is this file/code located? I'm on Windows...

@HuangLK
Copy link

HuangLK commented Mar 6, 2016

@InigoWD ...\Sublime Text 2\Packages\Sublime Bookmarks

@inigopascall
Copy link

Nope, I don't have this structure. I am using ST3 on Windows 7. In the following directory:

C:\Users\Inigo\AppData\Roaming\Sublime Text 3\Installed Packages\

I have the file "Sublime Bookmarks.sublime-package"

But it is unreadable. The documentation states a different protocol is requiried to manually modify packages. Hence my confusion. Where and how do I insert the code @kannus posted...?

Edit: Link not working. Here: http://docs.sublimetext.info/en/latest/extensibility/packages.html#overriding-packages

@gwenzek
Copy link

gwenzek commented Mar 6, 2016

@InigoWD The '.sublime-package' is just a Zip. You can just unzip it,
modify the code and rezip it. It's not really convenient so if you want to
do this frequently the simplest solution is to clone the plugin repository
inside your Packages/User folder.
On Mar 6, 2016 1:12 PM, "InigoWD" [email protected] wrote:

Nope, I don't have this structure. I am using ST3 on Windows 7. In the
following directory:

C:\Users\Inigo\AppData\Roaming\Sublime Text 3\Installed Packages\

I have the file "Sublime Bookmarks.sublime-package"

But it is unreadable. The documentation states a different protocol is
requiried to manually modify packages. Hence my confusion. Where and how do
I insert the code @kannus https://github.com/kannus posted...?


Reply to this email directly or view it on GitHub
#23 (comment)
.

@kannus
Copy link

kannus commented Mar 6, 2016

@InigoWD Sorry I did not mention how I even got to that file to change to being with but @gwenzek covered it. I simply unzipped that package (on windows, you probably need to rename it to something.zip, unzip it, modify source, zip it, rename the zip file back to sublime-package and install it again).

@inigopascall
Copy link

Thanks, both of you. So the steps I took (Windows 7) were:

  1. Located file C:\Users{user}\AppData\Roaming\Sublime Text 3\Installed Packages\Sublime Bookmarks.sublime-package and changed extension to .zip
  2. Created new folder C:\Users{user}\AppData\Roaming\Sublime Text 3\Packages\User\Sublime Bookmarks
  3. Copied the zip file to this folder and extracted it
  4. Modified line 323 of sublimebookmark.py as per @kannus' code

Started ST3....

That sound about right?

It's working so far...

@Drygord
Copy link

Drygord commented Feb 17, 2024

Fix for 2024? The bookmark sublime file is not present in installed packages folder. Seems it've been moved but it's still not working

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

8 participants