aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-05-18 13:09:39 +0100
committerStephen Blott2014-05-18 13:09:39 +0100
commitc16d0974cd7c688050c9f2f7e539d5db3077a567 (patch)
tree33e387d55a7dad8920973ade3869345fd4214d45
parenta1467b3f0ff2f7e3703edb032909980454763f1b (diff)
downloadvimium-c16d0974cd7c688050c9f2f7e539d5db3077a567.tar.bz2
Just ignore known and enumerated top-level folders.
-rw-r--r--background_scripts/completion.coffee22
1 files changed, 11 insertions, 11 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 54b94eb5..3e80526a 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -137,25 +137,25 @@ class BookmarkCompleter
@bookmarks = @traverseBookmarks(bookmarks).filter((bookmark) -> bookmark.url?)
@onBookmarksLoaded()
+ ignoreTopLevel:
+ 'Other Bookmarks': true
+ 'Mobile Bookmarks': true
+ 'Bookmarks Bar': true
+
# Traverses the bookmark hierarchy, and returns a flattened list of all bookmarks.
traverseBookmarks: (bookmarks) ->
results = []
bookmarks.forEach (folder) =>
- # folder is a chrome virtual root folder.
- folder.children.forEach((folder) =>
- # folder is one of the chrome, built-in folders ("Other Bookmarks", "Mobile Bookmarks", ...).
- folder.children.forEach((bookmark) =>
- # bookmark is a user-defined folder, or itself a bookmark.
- @traverseBookmarksRecursive bookmark, results))
- #
- # We do not add the (possible) bookmark itself. The user has used the "/" key to begin searching
- # within bookmark folders. It's not clear what that even means for top-level bookmarks.
- # results.push bookmark
+ @traverseBookmarksRecursive folder, results
results
# Recursive helper for `traverseBookmarks`.
traverseBookmarksRecursive: (bookmark, results, parent={pathAndTitle:""}) ->
- bookmark.pathAndTitle = if bookmark.title then parent.pathAndTitle + @folderSeparator + bookmark.title else parent.pathAndTitle
+ bookmark.pathAndTitle =
+ if bookmark.title and not (parent.pathAndTitle == "" and @ignoreTopLevel[bookmark.title])
+ parent.pathAndTitle + @folderSeparator + bookmark.title
+ else
+ parent.pathAndTitle
results.push bookmark
bookmark.children.forEach((child) => @traverseBookmarksRecursive child, results, bookmark) if bookmark.children