-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
History completion #547
History completion #547
Conversation
Adds a basic completion model implementation around the global browser history and registers that for the open command. Modifies WebHistory to add an __iter__ method and to use a dict instead of a set to store an entire HistoryEntry for each archived item instead of just the URL. Brief tests showed that the lookup time for set and dict are very similar. They are at least on the same order of magnitude. Testing membership of a list on the other hand, as was the case before a set was used, was four orders of magnitude slower on my machine.
I went to some effort to avoid duplipcating code which which leads to some arguably ugly class method calling.
Each new HistoryEntry is emitted after being added to the global history store. Current members of the HistoryEntry are `url` and `atime`. `title` should be coming soon.
We could just put all of the entries into the same dict and either have a
I think we shouldn't ignore the fragment. Think of single page apps that use the fragment for state and wanting to go back to that particular state from your history. |
Maybe I'm missing something (6:45 AM), but don't we basically have that already?
|
Two things here. One is to use `WebHistory._new_history` only as a to-save queue, so we now add entries to `_old_urls` when they are first created and can now no longer iterate of `_new_history` in `__iter__()`. Second is to stop blindly tacking new history entries on the end of the history completion model. It does involve iterating over the model to find the existing entry but we only do that if we know the duplicate is there, which is fast to check. This also ads another point of mutation to the history completion model which may prove problematic if it leads to more segfaults.
I got the segfault figured out:
In my code, I added the |
Oh goodie. Is that both the crashes that you experienced handled or just the one that was mysteriously fixed? Because so far I haven't managed to reproduce either. I am going to make a 64bit arch chroot to see if it is because of a difference in our setups. Currently I am on 32bit Debian testing with Qt at version 5.3.2. |
That's just the segfault which has been mysteriously fixed - I haven't looked at the exception yet. I've just had it happen twice yesterday after using your branch for some time, but I didn't investigate yet. |
The need for those were removed in #548.
- HistoryItem.atime now always should be an int/float. - The data for the sort role should also be an int, not a string. A float would also work, but maybe be slower for no real benefit.
Otherwise we would construct a QStandardItem with the QStandardItem(int rows, int columns = 1) constructor, which will most likely not do what we want.
I pushed commits to handle everything except that exception - I hope I'll have time to look at that later today. Quick question about dbd121a: Is there some reason you constructed a new |
I added another issue above - currently the models are created again for every window, which means this will take a lot of time. Instead, the completion models should be stored globally. |
I also found out how to reproduce the exception - and even though I'm not 100% sure why, it doesn't happen with the new code anymore. So the only thing left is making the models global instead of per-window. |
Before, we initialized the completions once for every window spawned, which was a waste of CPU-time and RAM. Now we only initialize them once, when the user uses the completion for the first time.
This is now handled as well, completions are now only loaded once, when they're used the first time (to not slow down startup time). However two people in
I'll profile it and see if I can optimize anything - but we probably should limit the amount of history loaded with a config option. |
This is now renamed to cmd-history-max-items to avoid confusion with the web history.
Instead of calling expandAll() and iterating through all items, we can just force the top-level items to be expanded.
That's also done, by default limited to 1000 items. I still want to do some testing and get some feedback on performance, and then I'll merge this! Thanks a lot again for getting started with this so I was motivated to finish it :) Also, sorry for the spam here, @toofar ;) |
Before, the item_added signal was emitted *after* an item was added, which means the on_history_item_added slot always assumed the item already is in the history.
I guess limiting the history for completion is pragmatic, it is definitely a lot smoother. Another option may be to just complete on I was testing with ~35,000 entries from my dwb history but with One last thing, non-ascii strings in URLs are percent encoded and they aren't currently decoded so you can't search for a URL with an umlaut or whatever. I just added a |
Yeah, and people who want unlimited history can still set
I don't like that, because many people don't even know a completion exists in dwb if it's not something which shows up immediately.
It's mainly the filtering it seems. If you run
Hmm, does the sorting take much time for you? Can you comment the sorting in
I'll take a look at that and then merge. |
We also use QUrl::toDisplayString for the completion so things like spaces or umlauts are decoded properly.
Before, if an URL was present early in the history and then again later, we didn't move it to the end of the OrderedDict. This means it won't be loaded in the completion.
@toofar - A few open questions:
|
Before we limited the history items we could simply call WebHistory's historyContains before iterating through all items in the history completion. Now however it's possible an item is in the real WebHistory, but not actually in the completion - so we always have to check the whole completion.
I must say I would welcome if there was an option for this and would probably use the tab variant, since most of the time I just enter urls and don't use history I prefer to save those cycles and have the smoother experience. The default can of course be showing history while typing, but I second that proposal! |
Unrelated: how do you make the checkboxes in issues like that? |
@flvi0 I opened #557 for that. |
Danke, I'll be using that. |
Nope, no reason. I probably didn't think about it or tried to reduce mutation for some reason.
I honestly thought I copied it from you and that you must have had it there for some reason. But I wrote it so I guess I was just being extra careful.
I definitely got a runtime error because of a nonetype there at some point. I am pretty sure I was trying to figure out the structure of the nested table-like models by trial and error. I guess was being defensive because I am not familiar with the codebase and the APIs it uses. |
Okay - I guess I'll leave it out for now, and then we'll see if there are any exceptions reported.
No worries! I'm just curious :) Soooo, time to merge this 👍 |
This is the continuation of #531 - related issue: #32.
/cc @toofar @fosskers
Open issues
self._history.historyContains(entry.url_string)
will still be True even if the entry is in the full history, but not actually in the completion.http://heise.de/
in my history completion even though it's on line 15085 of 15320 in my history file.WebHistory._old_urls
and inWebHistory._new_history
. I'm not sure what's the best way to fix that though.RuntimeError
because categoryQStandardItem
got deleted inhistory_changed
.histcomplete
branch when (after applying a small fix for the segfault) opening/closing a second window, and then opening a new URL.lambda
connected toWebHistory.item_added
doesn't get disconnected properly when the window was closed and the completion model was destroyed? I don't really get why, but it's not reproducible anymore with the new code not using alambda
.:open -w
Completer
object is created for eachCompletionView
currently, and thus for everyMainWindow
. This means opening a new window takes more time (~1s on my machine) and RAM.Completer
, but the model should be global instead.:repeat 20 open -w
and:quit
.Other things and nice-to-have
#
and empty fragment...completion -> timestamp-format
or so.qutebrowser/browser/history.py
is confusingThis change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)