Commit Graph

5390 Commits

Author SHA1 Message Date
Maxime Coste
d3f9358fdb Merge remote-tracking branch 'Qeole/pr/crash-colors' 2022-02-15 20:44:41 +11:00
Maxime Coste
b030fc4c07 Merge remote-tracking branch 'Screwtapello/validate_alpha-is-constexpr' 2022-02-15 20:43:43 +11:00
Tim Allen
d1ea2ffa60 Make Color::validate_alpha() a constexpr function.
We call it from a constexpr constructor, so it needs to be constexpr itself.

Fixes #4544.
2022-02-12 21:35:33 +11:00
Qeole
3abf2b8260 Faces: Check that underline colour comes before base/attributes markers
Parsing a (non-valid) font with a comma in the name of the base colour
makes Kakoune crash. It is not a valid face, but Kakoune should just
return an error message instead.

Reproducer:

    :set-face global foo ,red@,blue

Note the comma "," after the "@". This is not a valid base name, and it
leads to a crash. Let's see what happens.

At the beginning of parse_face(), we have the following code:

    auto bg_it = find(facedesc, ',');
    auto underline_it = bg_it == facedesc.end() ? bg_it : std::find(bg_it+1, facedesc.end(), ',');
    auto attr_it = find(facedesc, '+');
    auto base_it = find(facedesc, '@');
    [...]
    auto colors_end = std::min(attr_it, base_it);

After this:

- bg_it points to ",red@,blue"
- bg_it != facedesc.end(), so we have underline_it pointing to the first
  comma after bg_it. This means that underline_it points to ",blue"
- base_it points to "@,blue"
- attr_it points to the end of facedesc (no "+" marker), so colors_end
  points to base_it, "@,blue"

Later in the code, just after parsing the foreground and background
colours, we have:

    if (underline_it != facedesc.end())
        face.underline = parse_color({underline_it+1, colors_end});

When passing {underline_it+1, colors_end} to parse_color(), we pass in
fact iterators pointing to {",blue", "@,blue"}. Because the second one
starts _before_ the first one in the string, this means that the
resulting string is considered to have a _negative_ length.
parse_color() passes the string to str_to_color(), who fails to turn up
the colour, and attempts to throw:

    throw runtime_error(format("unable to parse color: '{}'", color));

The variable "color" still has this negative length, and this goes all
the way down to an assert in src/units.hh where we expect that string to
be >= 0, and we crash on the assertion failure.

For similar reasons, we also get a crash if the comma comes after the
marker for the face attributes:

    :set-face global foo ,red+,a

To fix both cases, let's add a check to make sure that the underline_it,
marked with a comma, never gets detected as present and pointing after
colors_end, be it "@" or "+".
2022-02-11 09:35:49 +00:00
Maxime Coste
33e81af0f3 Fix regex alternation execution priority
The ThreadedRegexVM implementation does not execute split opcodes as
expected: on split the pending thread is pushed on top of the thread
stack, which means that when multiple splits are executed in a row
(such as with a disjunction with 3 or more branches) the last split
target gets on top of the thread stack and gets executed next (when the
thread from the first split target would be the expected one)

Fixing this in the ThreadedRegexVM would have a performance impact as
we would not be able to use a plain stack for current threads, so the
best solution at the moment is to reverse the order of splits generated
by a disjunction.

Fixes #4519
2022-02-02 14:51:17 +11:00
Maxime Coste
4bd34caf4f Fix modified keys not being mappable in goto mode
The test was invalid, non-codepoint keys should be considered mappable.

Fixes #4521
2022-02-01 13:36:36 +11:00
Maxime Coste
bfbce2a1c1 Merge remote-tracking branch 'Screwtapello/fix-session-name-error' 2022-01-24 22:11:50 +11:00
Maxime Coste
f8a86149e5 Use strerror to display execve failures
Fixes #4501
2022-01-24 21:59:16 +11:00
Maxime Coste
6f135c0c8e Do not insert any end-of-line when piping data out
This will unfortunately break some use case which will require
using wrapper scripts to add the necessary newline. It is however
harder to do the contrary, and it makes a lot of other use case
possible, such as checksuming.

Fixes #3669
2022-01-24 21:53:33 +11:00
Maxime Coste
f4ff59f8b2 Restore goto case insensitiveness, refuse to map upper case
After a while it seems clear changing this is much more ergonomic
and restoring it with pure config is impractical as we need to map
all lower case keys.
2022-01-23 21:00:45 +11:00
Tim Allen
4bfb0c6b93 When reporting an invalid session name, report the correct name.
At this point, the session name has already been moved from the `session_name`
parameter to the `m_session` member variable.
2022-01-18 14:44:09 +11:00
Johannes Altmanninger
6f7c5aed10 Do not show custom completions when autocomplete is off
As reported in [1], completions provided by "set global completers
option=my_completion" activate insert mode autocompletion, even when
the autocomplete option does not have the insert mode flag.

This happens because InsertCompleter::on_option_changed() calls
InsertCompleter::setup_ifn(), which shows the completion pager.
Fix this by computing whether the completion pager is enabled;
otherwise we can return early from setup_ifn().
The completion pager is enabled if the autocompletion bit is set,
or if the user has requested explicit completion.

[1]: https://github.com/kak-lsp/kak-lsp/issues/585
2022-01-09 20:23:51 +01:00
Maxime Coste
f68e8313b2 Fix invalid line joining logic with multiple selection per line
Fixes #4476
2021-12-20 09:13:53 +11:00
Sidharth Kshatriya
02f9db616c Bug fix: use only iswlower() in RankedMatch::is_word_boundary() 2021-12-14 15:10:01 +05:30
Chris Webb
4a10220db8 Fix mode line inconsistency between normal and insert modes
In normal mode, the mode line contains "1 sel" or "n sels (k)" when n > 1,
whereas in insert mode, it contains "n sels (k)" even for n == 1. Change
the contents in insert mode to match normal mode.
2021-12-11 12:11:08 +00:00
Maxime Coste
6029ee9815 Fix explicit line completion
trim_indent call was incorrect, trim_indent is intended to work
on multi-line strings and trims trailing whitespace as well (could
benefit from a better name).

Fixes #4378
2021-12-11 09:34:51 +11:00
Maxime Coste
7648d56fc3 Fix parsing nul bytes in regex
Fixes #4460
2021-12-11 09:01:03 +11:00
Maxime Coste
b65df4bebf Fix spurious warning likely due to String::Data not being std compliant 2021-12-11 08:44:19 +11:00
Maxime Coste
658b6b0f1a Make space a named key to correctly handle shift modifier 2021-12-11 08:12:08 +11:00
Maxime Coste
716f1f967a Clang is still unhappy, trying another approach with defining my own concept 2021-11-25 22:32:10 +11:00
Maxime Coste
4122b64ecd Avoid using standard concepts
Turns out those are unimplemented in clang < 13, use custom code
instead.
2021-11-25 22:09:01 +11:00
Maxime Coste
28ac8adbfc Templatize parse_quoted to avoid utf8 decoding with ascii delimiter 2021-11-25 13:23:56 +11:00
Maxime Coste
16493a99bb small regex impl code style tweak 2021-11-25 09:59:45 +11:00
Maxime Coste
860b20ef0a Try to fix more CI failures related to C++20 2021-11-21 20:16:58 +11:00
Maxime Coste
532a7d7a9e Fix clang C++20 compilation issues 2021-11-21 20:06:14 +11:00
Maxime Coste
91550639bb More C++20 refactorings
Use CTAD instead of make functions, requires instead of enable_if
2021-11-21 11:41:50 +11:00
Maxime Coste
bea23c6bf2 Use std::remove_cvref instead of std::decay 2021-11-21 09:44:57 +11:00
Maxime Coste
ab9d78f50d Convert comparisons to spaceship operator 2021-11-21 09:44:56 +11:00
Maxime Coste
fb4cef5b61 Replace std::enable_if with requires
Introduce some concepts for enum and flags handling, goodbye and
thanks for all the fish std::enable_if.
2021-11-21 09:44:56 +11:00
Maxime Coste
ba379cba52 Micro-optimize regex character class/type matching
Also force-inline step_thread as function call overhead has a
mesurable impact.
2021-11-21 09:44:22 +11:00
Maxime Coste
8566ae14a0 Reduce the amount of Regex VM Instruction code
Merge all lookarounds into the same instruction, merge splits, merge
literal ignore case with literal...

Besides reducing the amount of almost duplicated code, this improves
performance by reducing pressure on the (often failing) branch target
prediction for instruction dispatching by moving branches into the
instruction code themselves where they are more likely to be well
predicted.
2021-11-21 09:44:18 +11:00
Maxime Coste
6a204c31ed Merge remote-tracking branch 'lenormf/debug_mode-gdb_script' 2021-11-21 09:36:25 +11:00
Maxime Coste
da3ddbf4fe Merge branch 'doc_highlighter_switch' of http://github.com/fennewald/kakoune 2021-11-21 09:35:14 +11:00
Carson
336c1d29b5 Documented -override switch for add-highlighter 2021-11-16 00:45:47 -05:00
Sidharth Kshatriya
dd92391036 Fixes #4432: JSON UI only shows stdin when connecting to an existing session
Only ui type Terminal is intended to be a user interactive session.
If your ui type is not Terminal, don't worry about making
the tty your stdin if fd 0 is not a tty.

This allows json-rpc commands sent via stdin to be acted up rather
than sent to a fifo (which is the default behavior for kakoune).

Does not change the behavior for Terminal ui sessions
2021-11-15 11:11:28 +05:30
Maxime Coste
e7100dc874 Recognize both <tab> and <c-i> as forward jump
Now that Kakoune opts into extended key reporting, <c-i> is correctly
reported and hence needs to be mapped to forward jump.

We still need to keep <tab> mapped to it for legacy terminals.

Should fix #4333
2021-11-11 13:29:42 +11:00
Frank LENORMAND
36166d8b0f src makefile: Install GDB types in debug mode 2021-11-08 13:39:55 +03:00
Maxime Coste
1b8574449f Kakoune 2021.11.08 2021-11-07 16:51:39 +11:00
Frank LENORMAND
6cadffa090 src highlighters: Factorise docstrings
Fixes #4367.
2021-11-05 11:30:35 +03:00
Frank LENORMAND
4eb8a100a8 src highlighters: Sort instantiations 2021-11-04 07:38:13 +03:00
Jason Felice
a70dbda54c use shifted key codes on kitty 2021-11-02 08:26:39 -04:00
Maxime Coste
19e2225153 Keep command_fifo read fd open instead of closing/reopening
Closing/reopening the read side seems to sometimes lead to
end-of-file not being received, leaving some extra data unexecuted.

The FDWatcher stays disabled during the executing of the fifo
commands so this should not enable any more commands to be executed
until we get back from the CommandManager and reset the FDWatcher
fd to to fifo read end.

Fixes #4410
2021-11-02 21:50:37 +11:00
Maxime Coste
e7adb01316 Merge remote-tracking branch 'sidkshatriya/remove-kak-history-file' 2021-11-02 21:09:25 +11:00
Maxime Coste
0f688656a4 Fix DECRPM parsing for 2026
As discovered in #4320 the previous code was buggy and would enable
synchronized output on any response.
2021-11-02 19:43:16 +11:00
Maxime Coste
8299d1da1f Fix pasting all from empty register
Raise an error if the register is empty for paste-all

Fixes #4414
2021-11-01 09:05:57 +11:00
Maxime Coste
d2e2caaae6 Fix incorrect reading logic and EAGAIN handling
This is one of the issues raised by #4410
2021-10-29 22:34:19 +11:00
Maxime Coste
be4659097c Complete alias command with existing alias names 2021-10-29 08:20:08 +11:00
Maxime Coste
874f3e0764 Fix terminal underline color not being properly reset 2021-10-29 07:51:29 +11:00
Maxime Coste
da10ce817e Kakoune 2021.10.28 2021-10-28 09:13:34 +11:00
Robert Clausecker
120e4b5a5d src/main.cc: Fix inline assembly syntax error on ARM
ARM uses @ as a comment character, so %progbits must be
used in place of @progbits here.  This change fixes the
build on armv7 FreeBSD 13.0.

Fixes		mawww/kakoune/issues#4385
See also	https://bugs.freebsd.org/259434
2021-10-25 15:17:49 +02:00