Commit Graph

249 Commits

Author SHA1 Message Date
Florian Bruhin
c590648077 Merge remote-tracking branch 'origin/pr/3613' 2018-03-13 08:39:36 +01:00
Florian Bruhin
34815f5cf8 Make bindings.default only settable in autoconfig.yml
Fixes #3131
2018-03-07 18:30:44 +01:00
Florian Bruhin
0e2a39da2a Fix tests for keyboard parsing change 2018-03-06 07:39:41 +01:00
Florian Bruhin
8deb38e22d Add test for :bind completion with invalid binding 2018-03-05 22:21:57 +01:00
Florian Bruhin
155a1901c0 Merge branch 'keys' 2018-03-04 22:50:41 +01:00
Florian Bruhin
067be7aaa2 Simplify mock checks 2018-03-02 06:33:56 +01:00
Florian Bruhin
fb7fa0cb49 Merge remote-tracking branch 'origin/pr/3652' 2018-03-02 06:31:00 +01:00
Ryan Roden-Corrent
d5e30fd728 Don't crash first completion update with min_chars.
When min_chars is nonzero, if the first command that opens the
completion has < min_chars on the word under the cursor, it triggers a
check for a condition where last_cursor_pos is None.

By setting last_cursor_pos=-1 we ensure that the completer always
updates the first time it is opened, and that there is never a check
against None.

This adds a test for the min_chars feature.

Resolves #3635.
2018-03-01 22:07:53 -05:00
Ryan Roden-Corrent
2965f954ba Resolve empty completion.timestamp_format crash.
Resolves #3628.
2018-03-01 07:54:20 -05:00
Florian Bruhin
5eb340d481 Add missing tests for completions 2018-02-27 15:55:00 +01:00
Florian Bruhin
fa29a0b686 Expect capitalized bindings in test_models 2018-02-27 06:58:39 +01:00
Florian Bruhin
8416e97c6c Fix type which is stubbed in test_models 2018-02-27 06:50:57 +01:00
Florian Bruhin
75181e16fa Fix test_models.py
The Config object got initialized via the config_stub fixture early, so we need
to force it to re-init its values after patching configdata.DATA.
2018-02-19 22:09:46 +01:00
bttner
e169e2165d Refactor TabbedBrowser from inheritance to composition 2018-02-19 14:29:05 +01:00
Florian Bruhin
6f028e9ad0 Update copyright years 2018-02-05 12:19:50 +01:00
Ryan Roden-Corrent
c290b3f80f Don't attempt completion if input starts with flag.
Always interpret the first word in the command string as the command to
offer completions for, even if that word looks like a flag.

Fixes #3460, where the command string `:-w open` would attempt to offer
completions for `open` but crash because the parsing was thrown off.
By moving the flag-stripping logic to _after_ we determine the command,
`:-w open` interprets `:-w` as the command. Since that is not a valid
command, we won't offer any completions.
2018-01-04 12:34:06 -05:00
Florian Bruhin
e65c0dd8a7 pylint: Re-enable bad-continuation
And lots and lots of whitespace changes.
2017-12-15 19:16:55 +01:00
Ryan Roden-Corrent
6420037dd9 Fix histcategory query reuse logic.
I mistakenly checked the length of wheres instead of words. This fixes
that check, renames 'wheres' to 'where_clause' to be clear
that it is a string and not an array, and adds a test.
2017-12-13 08:39:34 -05:00
Ryan Roden-Corrent
8909e03f1c Match url completion terms in any order.
Perviously, 'foo bar' would match 'foo/bar' but not 'bar/foo'. Now it
will match both, using a query with a WHERE clause like:

WHERE ((url || title) like '%foo%' AND (url || title) like '%bar%')

This does not seem to change the performance benchmark. However, it does
create a new query for every character added rather than re-running the
same query with different parameters. We could re-use queries if we
maintained a list like self._queries=[1_arg_query, 2_arg_query, ...].
However, it isn't clear that such a complexity would be necessary.

Resolves #1651.
2017-12-11 07:46:50 -05:00
Ryan Roden-Corrent
636f9edff6 History completion by both URL and title.
Resolves #1649.
2017-12-05 07:32:58 -05:00
Florian Bruhin
a137a29cce Style improvements
This adds a blank line and makes Completer arguments keyword-only to make their
meaning more clear.
2017-12-03 22:32:17 +01:00
Ryan Roden-Corrent
b610563e7f Don't show current window for :tab-give/:tab-take.
Resolves #3144.
2017-12-03 08:03:54 -05:00
Florian Bruhin
e9be357104 Merge remote-tracking branch 'origin/pr/3352' 2017-12-02 14:37:01 +01:00
Ryan Roden-Corrent
b6dcd4d387 Reapply "Hide quickmark/bookmark completion if empty."
This reverts commit e72e8b8556.

Now that the SQL category works in isolation, it is possible to hide
quickmarks/bookmarks when those categories are empty.

Fixes #960
2017-11-28 07:21:26 -05:00
Ryan Roden-Corrent
40e4e73e36 Ensure HistoryCategory works in isolation.
While QSortFilterProxyModel emits layoutChanged when changing the
pattern, QSqlQueryModel emits modelReset. As only layoutChanged was
connected, a HistoryCategory would only work in a model that also had at
least one ListCategory.

The simplest solution is to have the parent model emit the signal
directly. This also emits a single signal on a pattern change rather
that one for each child model.

Resolves #3016.
2017-11-27 11:49:32 -05:00
Florian Bruhin
75a8938e83 Add flake8-bugbear 2017-11-26 21:50:12 +01:00
Panagiotis Ktistakis
2bb8d404d2 Adjust :bind completion tests 2017-11-26 14:07:41 +02:00
Florian Bruhin
404f9ea1d0 Merge remote-tracking branch 'origin/pr/3290' 2017-11-15 07:31:10 +01:00
Florian Bruhin
e72e8b8556 Revert "Hide quickmark/bookmark completion if empty."
This reverts commit 23716f1212.

See #3016
Fixes #3288
Reopens #960
2017-11-14 13:29:58 +01:00
Ryan Roden-Corrent
b72343d126 Yank selected text with completion-item-yank.
If text is highlighted in the status command bar, completion-item-yank
should yank that rather than the selected completion item.

Resolves #3281.
2017-11-13 13:25:18 -05:00
Florian Bruhin
8057f5c281 Set __tracebackhide__ for _check_completions 2017-11-13 09:02:16 +01:00
Florian Bruhin
f6cc6677dd Remove hiding of commands
This was often confusing for people - let's instead just hide commands which are
not available in normal mode.
2017-11-13 09:02:16 +01:00
Ryan Roden-Corrent
23716f1212 Hide quickmark/bookmark completion if empty.
If there are no quickmarks/bookmarks, hide the entire category in url
completion. Note that this only hides the category if
quickmarks/bookmarks is empty to begin with. An empty category is still
shown if the completion pattern filters out all items in that category.

See #960.
2017-11-12 22:28:49 -05:00
Ryan Roden-Corrent
bb63f9fd92 Implement completion-item-yank.
Yank the text from the first column of the completion menu.
Resolves #1588.
2017-11-05 11:07:38 -05:00
Florian Bruhin
0f28804032
Merge pull request #3237 from rcorre/completionsort
Fix completion sorting
2017-11-03 14:36:42 +01:00
Ryan Roden-Corrent
a9926e44f0 Don't check date string in test_histcategory.
We really just need to check that the row exists here, the date doesn't
matter. Checking the date here is actually flaky with regards to time.
When running locally at 11:50 EST, it failed with:

```
assert self._model.data(self._model.index(row, col)) == item
AssertionError: assert '1969-12-31' == '1970-01-01'
- 1969-12-31
+ 1970-01-01
```

It was wrong to assume that an atime of 0 would always format to
1970-01-01.
2017-11-02 22:10:00 -04:00
Ryan Roden-Corrent
47447c047a Ensure completions are sorted after filtering.
I previously removed the sorting logic from SortFilter thinking it was
unnecessary if we construct the model with a sorted list. However, this
only worked when no pattern was set, and the items are misordered as
soon as a pattern is input.

This patch reintroduces alpha-sorting, which can be disabled by passing
sort=False to the ListCategory constructor. The session completion test
had to be tweaked as it simulated the incorrect assumption that the
session list is not alpha-ordered; sessions come out of the
session-manager pre-sorted so we may as well use alpha-sorting in the
session completion model.

Resolves #3156.
2017-11-02 22:10:00 -04:00
Luca Benci
c28d681736 Change test to avoid calling private functions 2017-11-02 19:42:33 +01:00
Luca Benci
35597a7c01 Change tests for trailing-space behaviour change 2017-10-31 23:15:11 +01:00
Luca Benci
249164eb9b Fix test_quickcomplete_flicker
The test needed to be fixed because of how the completer behaviour
changed.

Before:
completer always scheduled a completion update on selection changed,
but the updates themselves were ignored if not needed.

Now:
completer only schedules completion updates when actually needed, but
never ignores a completion update.

So, before it was correct to check whether `set_model` was called, now
we must check if the completion was actually scheduled. This can be
done by checking the parameters with which `_change_completed_part`
is called, since a completion is scheduled only when `immediate=True`
2017-10-27 22:25:41 +02:00
Michael Hoang
249e497d36 Add test for window completion 2017-10-11 17:18:13 +11:00
Florian Bruhin
42550cd2e6 Merge remote-tracking branch 'origin/pr/3048' 2017-10-04 06:47:48 +02:00
Florian Bruhin
22088d9f7b Remove --force for :bind and config.bind(...)
Turns out --force is just in the way for most people, and at least for default
bindings it's easy to reset them.

Also, it makes :config-source fail when config.py contains keybindings.

Closes #3049
2017-10-03 20:43:38 +02:00
Florian Bruhin
3772084cbf Adjust test_histcategory for NOT NULL constraints 2017-10-03 10:28:36 +02:00
Florian Bruhin
6573888dc6 Fix :bind completion with invalid commands
Now that Command doesn't validate things anymore, we can't rely on parsing to
work.
2017-09-27 11:10:25 +02:00
Florian Bruhin
4e46c34e5a Use .assert_not_called() for mocks 2017-09-22 19:58:38 +02:00
Florian Bruhin
cb57525f69 Fix whitespace 2017-09-21 13:43:30 +02:00
Ryan Roden-Corrent
f9440b8026 Use CommandParser for configmodel.bind.
The parsing bind() did manually is now available through CommandParser.
Resolves #2952.

This also adds a unit test for the case when there is no current
binding, as I broke that while working on this and there was no test to
catch it :)
2017-09-20 07:05:38 -04:00
Florian Bruhin
62b30af12a Fix unit tests for end2end SQL change 2017-09-17 11:49:42 +02:00
Florian Bruhin
4f6e085be8 Quote a completed value if it contains " 2017-09-15 22:17:38 +02:00