bollu / sublimeBookmark

a better bookmark system for SublimeText
Apache License 2.0
133 stars 30 forks source link

Bookmarks removed if file closed? #23

Open NeQuissimus opened 10 years ago

NeQuissimus commented 10 years ago

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:

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 commented 10 years ago

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 commented 10 years ago

@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 commented 9 years ago

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 commented 9 years ago

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.

untoreh commented 9 years ago

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 commented 8 years ago

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 commented 8 years ago

@kannus it works!

inigopascall commented 8 years ago

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

HuangLK commented 8 years ago

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

inigopascall commented 8 years ago

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 commented 8 years ago

@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" notifications@github.com 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 https://github.com/bollu/sublimeBookmark/issues/23#issuecomment-192880580 .

kannus commented 8 years ago

@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 commented 8 years ago

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 commented 5 months ago

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