Commit Graph

20 Commits

Author SHA1 Message Date
Lembrun e8b05af233 Qtbot methods changed to snake case,snake case check added 2021-02-26 22:07:08 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Florian Bruhin 9e1ab36172 Make sure all Qt regexes are valid 2020-11-25 18:58:33 +01:00
Florian Bruhin 5aebc55415 old qt: Adjust various comments/outputs 2020-11-04 18:30:04 +01:00
Florian Bruhin 99349401c3 Remove benchmark decorator 2020-08-24 18:27:30 +02:00
Florian Bruhin 38dd53c1d9 Fix lint 2020-08-24 17:42:55 +02:00
Florian Bruhin ab428305be Add completion highlighting benchmark 2020-08-24 16:57:46 +02:00
Andrew Carlotti 67c8f997be Add tests for 4-byte character and substring completion issues 2020-08-16 16:50:11 +01:00
Andrew Carlotti 78dbfb4505 Sort words by length in completion pattern
This makes e.g. "an anomaly" match correctly, rather than matching "an" twice.
Idea from arza-zara in #5111

Also move regexp construction into _Highlighter to facilitate unit testing
2020-08-16 16:33:54 +01:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
Florian Bruhin d8c02f495e Add highlighting test 2019-01-13 10:36:14 +01:00
Florian Bruhin 587b11f60d Make completion highlighting case-insensitive again
Fixes #4297
2018-10-06 09:57:01 +02:00
Ryan Roden-Corrent 0fed563a02
Use QSyntaxHighlighter for completion.
This is a more "Qt" way of highlighting syntax, and works around the
problems of #4199 without resorting to complicated html escaping.

The tests are more straightforward with less mocking, but do involve
testing a private class.
2018-09-22 12:13:28 -04:00
Ryan Roden-Corrent 2eacf4bd94
Clean up completiondelegate tests.
Respond to code review comments to reduce mocking and clean up comments.
2018-09-18 20:40:06 -04:00
Ryan Roden-Corrent 4f733333c3
Remove unused imports in test_completiondelegate. 2018-09-15 14:45:18 -04:00
Ryan Roden-Corrent 102c6b99dd
Don't highlight html escapes in completion.
Resolves #4199.

To avoid accidentally highlighting characters that were introduced by
html escaping the text before feeding it to setHtml, we can't just
escape the whole string before adding the highlighting. Instead, we need
to break the string up on the pattern, format and escape the individual
parts, then join them back together.

re.escape includes empty strings if there is a match at the start/end,
which ensures that matches always land on odd indices:

https://docs.python.org/3/library/re.html#re.split

> If there are capturing groups in the separator and it matches at the
> start of the string, the result will start with an empty string. The
> same holds for the end of the string
2018-09-15 14:06:28 -04:00
Ryan Roden-Corrent 4f99af5876
Don't escape quotes in completion text.
Resolves the example case in #4199, but not the larger problem. We don't
need to escape quotes as we don't put the string in an attribute value.
From the docs at
https://docs.python.org/3/library/html.html#html.escape:

> If the optional flag quote is true, the characters (") and (') are also
> translated; this helps for inclusion in an HTML attribute value
> delimited by quotes, as in <a href="...">.

Escaping quotes means we end up with a literal &#x27; in the completion
view wherever there is a quote in the source text.

However, problem in #4199, where unexpected parts of the text are
highlighted, can also happen with '<', '>', and '&', which still must be
escaped.
2018-09-15 13:39:49 -04:00
Ryan Roden-Corrent 28c8e5682a
Unit test CompletionItemDelegate.paint.
There were no unit tests for this whole module. It is difficult to test
due to all the private logic and Qt dependencies, but with a lot of
mocking we can at least validate some of the text handling.

This is a setup to start testing the solution to #4199.

I picked '{' and '}' as placeholders in the test data because they draw
the eye to the 'highlighted' part, and vim even highlights them with
python syntax highlighting. It could be confusing though, as they look
like format strings but are not used that way.
2018-09-15 13:34:07 -04:00