Commit Graph

4041 Commits

Author SHA1 Message Date
Maxime Coste
f02b2645da Regex: validate that our custom impl gets the same results as boost regex
In addition to running boost regex, run our custom regex and compare
the results to ensure the two regex engine agree.
2017-11-01 14:05:14 +08:00
Maxime Coste
76dcfd5c52 Regex: support escaping characters in character classes 2017-11-01 14:05:14 +08:00
Maxime Coste
3d2262bebf Regex: add support for case insensitive matching, controlled by (?i) 2017-11-01 14:05:14 +08:00
Maxime Coste
7673781751 Regex: use \A \z for subject start/end
This is the most common syntax in various regex variants.
2017-11-01 14:05:14 +08:00
Maxime Coste
0bdfdac5c5 Regex: Implement lookarounds for fixed literal strings
We do not support anything else than a plain literal string for
lookarounds.
2017-11-01 14:05:14 +08:00
Maxime Coste
e96cd29f0e Regex: Support non greedy quantifiers 2017-11-01 14:05:14 +08:00
Maxime Coste
e4004a7b7f Regex: Add support for \h and \H "horizontal blank" character classes 2017-11-01 14:05:14 +08:00
Maxime Coste
4ac0d35d1e Regex: Add support for \K that reset the start capture 2017-11-01 14:05:14 +08:00
Maxime Coste
2f450e0080 Regex: Add support for \Q...\E quoted parts 2017-11-01 14:05:14 +08:00
Maxime Coste
7a313ddafe Regex: small error message improvement 2017-11-01 14:05:14 +08:00
Maxime Coste
c282b699d7 Regex: fix support for - at end of a character class 2017-11-01 14:05:14 +08:00
Maxime Coste
e41d228af8 Regex: Disable dumping regex instructions by default in unit tests 2017-11-01 14:05:14 +08:00
Maxime Coste
d5048281a6 Regex: slight cleanup of the unit tests 2017-11-01 14:05:14 +08:00
Maxime Coste
f7468b576e Regex: Refactor regex compilation to a regular RegexCompiler class 2017-11-01 14:05:14 +08:00
Maxime Coste
d5717edc9d Regex: improve regex parse error reporting
Display the place where parsing failed, refactor code to make
RegexParser a regular object.
2017-11-01 14:05:14 +08:00
Maxime Coste
080160553c Regex: support escaped character classes 2017-11-01 14:05:14 +08:00
Maxime Coste
1a8ad3759f Regex: fix handling of strict quantifiers {N}
Previous behaviour was treating {N} as {N,}
2017-11-01 14:05:14 +08:00
Maxime Coste
be157453ad Regex: Use a std::function based "Matcher" op to implement character classes
This is more extensible and should allow easier support for non ranges
classes.
2017-11-01 14:05:14 +08:00
Maxime Coste
eb1015cdfb Regex: whenever Kakoune compiles a regex, pass it to the custom impl as well
That way we can see which features are missing.
2017-11-01 14:05:14 +08:00
Maxime Coste
002aba562f Regex: work on unicode codepoints instead of raw bytes 2017-11-01 14:05:14 +08:00
Maxime Coste
75608ea223 Regex: when in full match mode, do not accept trailing data 2017-11-01 14:05:14 +08:00
Maxime Coste
490c130e41 Regex: Implement leftmost matching
Ensure threads are maintained in "priority" order, by having two
split instruction (prioritizing parent or child).
2017-11-01 14:05:14 +08:00
Maxime Coste
182b70cb0a Regex: Add initial support for character ranges 2017-11-01 14:05:14 +08:00
Maxime Coste
52678fafa1 Regex: Add support for searching
Always compile a `.*` as the first instructions in a regex bytecode,
depending on the match or search mode, the RegexVM will either execute
this or skip it and start directly at the matching bytecode.
2017-11-01 14:05:14 +08:00
Maxime Coste
f7b8c1c79d Regex: cleanup and reorganize regex code and improve capture support
Introduce the CompiledRegex class, rename ThreadedExecutor to
ThreadedRegexVM, remove the RegexProgram namespace.
2017-11-01 14:05:14 +08:00
Maxime Coste
023511deff Regex: WIP support for saving captures 2017-11-01 14:05:14 +08:00
Maxime Coste
ad546e516a Regex: Small comment tweaks 2017-11-01 14:05:14 +08:00
Maxime Coste
46a113e10a Regex: Add support for curly braces count expressions 2017-11-01 14:05:14 +08:00
Maxime Coste
d04c60b911 Regex: Add support for subject begin/end assertion (\` and \') 2017-11-01 14:05:14 +08:00
Maxime Coste
9c5d539616 Regex: Add word boundary assertion support 2017-11-01 14:05:14 +08:00
Maxime Coste
a9a04e81b0 Regex: Ensure we only ever have a single thread on a given instruction 2017-11-01 14:05:14 +08:00
Maxime Coste
ee42c6b0ba Regex: add unit test to check the ".*" construct 2017-11-01 14:05:14 +08:00
Maxime Coste
4010c44fc0 Regex: Make the Split op only take a single offset parameter
Split now creates a new thread and keep the current one running, as
all of its uses are compatible with this behaviour, which enable a
more compact compiled code.
2017-11-01 14:05:14 +08:00
Maxime Coste
f9dc6774b9 Regex: Introduce RegexProgram::ThreadedExecutor and add line end/begin impl 2017-11-01 14:05:14 +08:00
Maxime Coste
a448e1e222 Regex: Code cleanup in the regex impl 2017-11-01 14:05:14 +08:00
Maxime Coste
8c9976ea72 Regex: Add initial, exploratory work on a custom regex engine 2017-11-01 14:05:14 +08:00
Maxime Coste
797a0cb062 Add another assert to try to catch #1506 2017-11-01 14:04:42 +08:00
Maxime Coste
94a0c9bb45 Highlighters does not need to inherit from HighlighterGroup
Just compose, to avoid coupling Highlighters with the Highlighter
interface. And yeah, that naming is a bit confusing.
2017-10-31 13:53:08 +08:00
Maxime Coste
6272847ace Prompt: display the fallback text everytime the prompt is empty 2017-10-31 12:54:21 +11:00
Maxime Coste
6d78b06405 Do not auto apply the fallback regex when in regex prompts
Fixes #1653
2017-10-30 18:58:47 +11:00
Maxime Coste
cd215ccee9 Do not allow opening files whose size we cannot express in an int 2017-10-30 18:58:47 +11:00
Maxime Coste
40eb598065 Makefile: Use pkg-config on Linux to get the ncurses compilation flags
Fixes #1659
2017-10-30 17:35:51 +11:00
Maxime Coste
43d470f286 Slight cleanup of select_surrounding implementation 2017-10-28 13:43:04 +08:00
Maxime Coste
7064e890f5 Update breaking changes message 2017-10-28 13:43:04 +08:00
Maxime Coste
d49555fc75 Move highlighters into Scopes
That means we can now have highlighters active at global, buffer, and
window scope. The add-highlighter and remove-highlighter syntax changed
to take the parent path (scope/group/...) as a mandatory argument,
superseeding the previous -group switch.
2017-10-28 13:43:04 +08:00
Maxime Coste
9a449a3344 Display the fallback value in prompts
Fixes #1654
2017-10-28 10:07:28 +08:00
Maxime Coste
7062022187 HashMap: Tolerate reserving for 0 elements
Fixes #1652
2017-10-27 11:03:43 +08:00
Maxime Coste
75767f5cb5 Fix infinite loop shell_complete
Fixes #1648
2017-10-25 11:26:03 +08:00
Maxime Coste
ab9283bc37 Merge remote-tracking branch 'net/master' 2017-10-25 11:13:42 +08:00
Net
74202fab45 Rename br* colors to bright-* 2017-10-24 23:08:22 -04:00
Maxime Coste
654e3fcb46 Fix regions highlighter infinite loops when regex matches empty ranges 2017-10-25 10:39:35 +08:00
Delapouite
d5b6669a83 Add distinct w (curr buf) / W (all buf) word completion for <c-x> 2017-10-24 22:47:43 +02:00
Net
2b44e93f79 Support bright named colors 2017-10-22 14:30:49 -04:00
Maxime Coste
600ba45189 Add missing include to meta.hh 2017-10-21 05:30:43 +08:00
Maxime Coste
d6cb10d693 Disable constexpr keymap as it breaks compilation with gcc 5 2017-10-20 19:12:21 +08:00
Maxime Coste
723bb2b175 Merge remote-tracking branch 'fsub/master' 2017-10-20 17:28:06 +08:00
Maxime Coste
7c06667bdf Make the normal mode keymap a compile time hash map
This hash map is now fully constexpr, and ends up stored in the read
only data segment instead of being recomputed at each startup.
2017-10-20 12:21:22 +08:00
Maxime Coste
d486ea84e5 Constexprify various hash functions 2017-10-20 12:21:22 +08:00
Maxime Coste
ddff35e5ab Move keymap as an implementation detail of the normal mode keys
Only expose a free function that tries to get the NormalCmd from a
key.
2017-10-20 12:21:22 +08:00
fsub
a70128a4cf Avoid some warnings in optimized builds 2017-10-19 22:20:44 +02:00
Maxime Coste
ddc307b8e9 Optimize CommandManager::execute handling of tokens
Instead of walking a list of tokens and inserting eventual new
ones in the middle, use a stack of token and push new ones on top.
2017-10-17 10:25:20 +08:00
Maxime Coste
145cf843dd Add a fail command to explicitely raise an error 2017-10-17 10:25:16 +08:00
Maxime Coste
89f016d871 Refactor column highlighter to make it more robust
Support arbitrary orders for column highlighters (it was previously
failing when column highlighters were not applied in column order).

Fix show_matching tab handling at the same time (horizontal scrolling,
tab characters and show_matching were behaving badly).

Window highlighting now runs user highlighters, then built-ins for each
phases, instead of running all phases for user highlighters, then all
phases for built-ins.

We now consider unprintable character to be 1-column width as we know
we will display them as "�".

Fixes #1615
Fixes #1023
2017-10-12 14:46:15 +08:00
Maxime Coste
78d7d512cb Fix utf8::to_previous that could go before the begin iterator 2017-10-10 10:53:24 +08:00
Maxime Coste
079cfbc6ac Remove unused forward declaration 2017-10-10 10:52:58 +08:00
Maxime Coste
6ada6e6d77 Move all non-core string code to string_utils.{hh,cc} 2017-10-10 10:52:32 +08:00
Maxime Coste
d1b9c24afc Make Server outlive buffer manager
Fixes crashes when trying to access the server to get the session
on hooks run during destruction of other managers.

Fixes #1622
2017-10-10 10:49:30 +08:00
Maxime Coste
80d2506c34 Make utf8_iterator traits clear about it returning non-references 2017-10-07 21:54:59 +08:00
Maxime Coste
e18836aea7 Add is_upper and is_lower helper unicode functions 2017-10-07 21:54:55 +08:00
Maxime Coste
ca17fbbeb9 Merge remote-tracking branch 'Delapouite/docs-scroll' 2017-10-07 21:51:37 +08:00
Maxime Coste
a5ae21d70d Move HookManager::Hook definition in the cpp
This avoids including regex.hh in the header.
2017-10-06 13:58:04 +08:00
Maxime Coste
18705a0097 Add missing operator+= and -= on utf8_iterator
Fix operator== and != that were non-const as well.
2017-10-06 13:57:54 +08:00
Maxime Coste
cbb6e9ea0f Merge remote-tracking branch 'Delapouite/client_list' 2017-10-06 13:53:55 +08:00
Maxime Coste
8900d06646 Merge remote-tracking branch 'Delapouite/complete-line' 2017-10-06 13:50:42 +08:00
Maxime Coste
3cfd3a3276 Merge remote-tracking branch 'Delapouite/debug-mappings' 2017-10-06 13:49:52 +08:00
Maxime Coste
1b22472ce8 Remove unneeded regex.hh include in color.cc 2017-10-06 13:48:30 +08:00
Maxime Coste
1a20e26cc4 Allow itersel with draft context to change the buffer
That way we can cater to the use case of executing some keys for
`:grep` matches with `exec -itersel -draft :grep-jump<ret>...`
2017-10-06 13:48:16 +08:00
Maxime Coste
30ab437777 Add more constexpr to flags wrapping functions 2017-10-06 13:48:01 +08:00
Maxime Coste
75d2eb2b79 formatting tweak 2017-10-06 13:47:30 +08:00
Delapouite
d03858280a Add client_list var 2017-10-05 16:41:36 +02:00
Delapouite
0e62518d89 Docs: add missing normal keys <c-[bfud]> 2017-10-04 12:47:56 +02:00
Delapouite
a63cf00b05 Add debug mappings 2017-10-03 23:00:08 +02:00
Delapouite
6bfc99bf08 Add 'line' in completers option as a way to force explicit <c-x>f 2017-10-02 18:45:11 +02:00
Maxime Coste
0da5cabbfe Distinguish between modes being disabled temporarily and definitely
That way, insert mode knows when it can restore selections/avoid eol
instead of (wrongly) doing it in the destructor that ends up running
unpredictibly (as the mode is kept alive during its on_key call, even
though it can happen that it is not the active mode anymore at the end
of that call).

Fixes #1580
2017-09-28 11:11:29 +08:00
Maxime Coste
100be4b836 Merge remote-tracking branch 'Delapouite/runtime-error' 2017-09-28 10:39:44 +08:00
Maxime Coste
a727e0fa0a Merge remote-tracking branch 'Delapouite/jump' 2017-09-28 10:38:42 +08:00
Delapouite
c7c8c14561 Display selections count in insert mode the same it's displayed in normal mode 2017-09-27 18:47:37 +02:00
Delapouite
7224fe3840 Convert status info into proper runtime_errors 2017-09-27 17:53:52 +02:00
Delapouite
6b339b7a97 Add status info when navigating through jumplist (<c-o>, <c-i>) 2017-09-27 17:26:39 +02:00
Maxime Coste
76f072a786 Removing the local client due to SIGHUP is not graceful
That means we will now backup modified buffers if that client was
the last.

Should improve things for #1590
2017-09-27 11:08:55 +08:00
Delapouite
25f25df8f5 Add selections_desc format to select autoinfo 2017-09-26 12:51:52 +02:00
Maxime Coste
626ccc09cc Merge remote-tracking branch 'Delapouite/next-history-id' 2017-09-23 13:18:58 +09:00
Maxime Coste
3a5bb051a8 Small code style tweak 2017-09-23 13:18:00 +09:00
Maxime Coste
002e77534f Merge remote-tracking branch 'occivink/quit-on-esc' 2017-09-23 13:13:51 +09:00
Maxime Coste
8107087510 Merge remote-tracking branch 'Delapouite/commands-docstring' 2017-09-23 13:12:03 +09:00
Maxime Coste
0dd9bdd11f Merge remote-tracking branch 'Delapouite/indent-count' 2017-09-23 13:11:19 +09:00
Delapouite
0b310b64ad Add count support for indent / deindent 2017-09-21 12:26:22 +02:00
Olivier Perret
a20ecf6b00 Use <esc> to exit on-key modes 2017-09-21 11:53:10 +02:00
Delapouite
3c05b11196 Fix missing spaces / new lines in commands docstring 2017-09-21 10:56:20 +02:00
Delapouite
b46c9ac630 Add max_history_id in status printed with <a-u> and <a-U> 2017-09-20 07:32:45 +02:00