Remove entries from History/Domain completers when they're removed on chrome. #715

Merged
merged 9 commits into from Nov 13, 2012

Conversation

Projects
None yet
2 participants
@smblott-github
Collaborator

smblott-github commented Nov 11, 2012

Currently, if a history entry is removed in chrome (or the entire history is removed), then the effects do not propagate into vimium until the next restart.

This is a pretty inconsistent UX.

The attached code fixes this inconsistency.


(Edit: Comments regarding bug in binarySearch deleted.)

smblott-github added some commits Nov 11, 2012

Remove history entries.
When a chrome history entry is removed, remove that entry from our
history too.  Same when the entire history is removed.
@smblott-github

This comment has been minimized.

Show comment
Hide comment
@smblott-github

smblott-github Nov 11, 2012

Collaborator

Doh! A short walk on the beach and I see how binarySearch is working. I withdraw (and apologize for) the "bug" comments above.

Collaborator

smblott-github commented Nov 11, 2012

Doh! A short walk on the beach and I see how binarySearch is working. I withdraw (and apologize for) the "bug" comments above.

@philc

View changes

background_scripts/completion.coffee
@@ -169,7 +169,7 @@ class HistoryCompleter
# The domain completer is designed to match a single-word query which looks like it is a domain. This supports
# the user experience where they quickly type a partial domain, hit tab -> enter, and expect to arrive there.
class DomainCompleter
- domains: null # A map of domain -> history
+ domains: null # A map of domain -> { entry: <historyEntry>, referenceCount: <count> }

This comment has been minimized.

@philc

philc Nov 11, 2012

Owner

Let's add a comment here to explain what reference count is and why it exists.

@philc

philc Nov 11, 2012

Owner

Let's add a comment here to explain what reference count is and why it exists.

@philc

View changes

tests/unit_tests/completion_test.coffee
@@ -41,6 +41,9 @@ context "HistoryCache",
should "return length - 1 if it should be at the end of the list", ->
assert.equal 0, HistoryCache.binarySearch(3, [3, 5, 8], @compare)
+ should "return one passed end of list (so: list.length) if greater than last element in list", ->

This comment has been minimized.

@philc

philc Nov 11, 2012

Owner

Great, nice test!

@philc

philc Nov 11, 2012

Owner

Great, nice test!

@philc

View changes

tests/unit_tests/completion_test.coffee
@@ -75,6 +80,30 @@ context "HistoryCache",
HistoryCache.use (@results) =>
assert.arrayEqual [newSite, @history1], @results
+ should "remove pages from the history, when page is not in history", ->

This comment has been minimized.

@philc

philc Nov 11, 2012

Owner

The name of this test is a bit confusing

@philc

philc Nov 11, 2012

Owner

The name of this test is a bit confusing

@philc

View changes

tests/unit_tests/completion_test.coffee
@@ -120,6 +155,35 @@ context "domain completer",
should "returns no results when there's more than one query term, because clearly it's not a domain", ->
assert.arrayEqual [], filterCompleter(@completer, ["his", "tory"])
+ should "remove 1 matching domain entry", ->

This comment has been minimized.

@philc

philc Nov 11, 2012

Owner

These tests should be wrapped in a context to group them and describe which area they're testing, and it looks like filterCompleter(@completer, ["story"]) # Force installation of @onVisitRemovedListener. should be in a setup block

@philc

philc Nov 11, 2012

Owner

These tests should be wrapped in a context to group them and describe which area they're testing, and it looks like filterCompleter(@completer, ["story"]) # Force installation of @onVisitRemovedListener. should be in a setup block

@philc

View changes

tests/unit_tests/completion_test.coffee
+
+ should "remove 3 (all) matching domain entries", ->
+ filterCompleter(@completer, ["story"]) # Force installation of `@onVisitRemovedListener`.
+ @onVisitRemovedListener { allHistory: false, urls: [ @history2.url ] }

This comment has been minimized.

@philc

philc Nov 11, 2012

Owner

No spaces between the array brackets

@philc

philc Nov 11, 2012

Owner

No spaces between the array brackets

@philc

This comment has been minimized.

Show comment
Hide comment
@philc

philc Nov 11, 2012

Owner

This is a nice case to handle, thanks for tackling it. If you can make the requested changes we'll merge it in.

Owner

philc commented Nov 11, 2012

This is a nice case to handle, thanks for tackling it. If you can make the requested changes we'll merge it in.

@smblott-github

This comment has been minimized.

Show comment
Hide comment
@smblott-github

smblott-github Nov 11, 2012

Collaborator

Thanks @philc -- I think all of your issues are addressed now.

Collaborator

smblott-github commented Nov 11, 2012

Thanks @philc -- I think all of your issues are addressed now.

@philc

This comment has been minimized.

Show comment
Hide comment
@philc

philc Nov 13, 2012

Owner

lgtm, thanks!

Owner

philc commented Nov 13, 2012

lgtm, thanks!

philc added a commit that referenced this pull request Nov 13, 2012

Merge pull request #715 from smblott-github/history--remove-entries
Remove entries from History/Domain completers when they're removed on chrome.

@philc philc merged commit 32e506d into philc:master Nov 13, 2012

1 check passed

default The Travis build passed
Details

davidwallacejackson pushed a commit to davidwallacejackson/vimium that referenced this pull request Apr 3, 2014

davidwallacejackson pushed a commit to davidwallacejackson/vimium that referenced this pull request Apr 3, 2014

Merge pull request #715 from smblott-github/history--remove-entries
Remove entries from History/Domain completers when they're removed on chrome.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment