summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-02-22Remove unnecessary workaround in Buffer::insertMaxime Coste
2022-02-18Do not keep MappedFile fd openedMaxime Coste
According to the mmap man page this is not necessary, and this avoids exposing the fd.
2022-02-15Merge remote-tracking branch 'krobelus/c-n-autocomplete'Maxime Coste
2022-02-15Merge remote-tracking branch 'krobelus/different-select-cmd-no-dupe'Maxime Coste
2022-02-15Merge remote-tracking branch 'Qeole/pr/crash-colors'Maxime Coste
2022-02-15Merge remote-tracking branch 'Screwtapello/validate_alpha-is-constexpr'Maxime Coste
2022-02-12Make Color::validate_alpha() a constexpr function.Tim Allen
We call it from a constexpr constructor, so it needs to be constexpr itself. Fixes #4544.
2022-02-11Filter duplicate completions only if they have the same select cmdJohannes Altmanninger
Given a completer option with two applicable completions text|select-cmd1|menu-text1 text|select-cmd2|menu-text2 Kakoune will only show one of them, because they will insert the same text. Some language servers send completions like this, for example if two different importable modules provide the same name. This can be reproduced using intelephense in this PHP file (cursor is %()) <?php namespace namespace1; class sometype {} ?> <?php namespace namespace2; class sometype {} ?> <?php namespace test; some%() ?> Both completions insert "sometype". The import statement will be added in an InsertCompletionHide hook by kak-lsp (it uses select-cmd to determine which completion was selected). To support this use case, refine the duplicate detection to not filter out completions with different select-cmd values.
2022-02-11Faces: Check that underline colour comes before base/attributes markersQeole
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-07Make <c-n> show completion menu again when autocomplete is offJohannes Altmanninger
As pointed out in [1], when insert mode autocomplete is disabled, <c-n> could be used to activate insert mode completions temporarily [2]. This regressed in 6f7c5aed (Do not show custom completions when autocomplete is off, 2022-01-03). Fix this by enabling completions on <c-n>/<c-p>. This allows us to remove a special case for explicit completers. Alternative behavior (future?): make <c-n> toggle completion like <c-o>. This can be done today, as suggested by Screwtape on IRC: map global insert <c-n> %{<c-o><c-n><a-;>:toggle-ctrl-n<ret>} define-command toggle-ctrl-n %{ hook global InsertCompletionShow .* %{ map window insert <c-n> <c-n> } hook global InsertCompletionHide .* %{ unmap window insert <c-n> <c-n> } } [1] https://github.com/mawww/kakoune/pull/4493#issuecomment-1031189823 [2] <c-n> completion only lives for the lifetime of the completion menu, whereas <c-o> lasts until you exit insert mode. This means that autocompletion is much more convenient than <c-n> or <c-x>f, because those require an explicit completion request for each path component.
2022-02-02Fix regex alternation execution priorityMaxime Coste
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-01Fix modified keys not being mappable in goto modeMaxime Coste
The test was invalid, non-codepoint keys should be considered mappable. Fixes #4521
2022-01-24Merge remote-tracking branch 'Screwtapello/fix-session-name-error'Maxime Coste
2022-01-24Use strerror to display execve failuresMaxime Coste
Fixes #4501
2022-01-24Do not insert any end-of-line when piping data outMaxime Coste
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-23Restore goto case insensitiveness, refuse to map upper caseMaxime Coste
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-18When reporting an invalid session name, report the correct name.Tim Allen
At this point, the session name has already been moved from the `session_name` parameter to the `m_session` member variable.
2022-01-09Do not show custom completions when autocomplete is offJohannes Altmanninger
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
2021-12-20Fix invalid line joining logic with multiple selection per lineMaxime Coste
Fixes #4476
2021-12-14Bug fix: use only iswlower() in RankedMatch::is_word_boundary()Sidharth Kshatriya
2021-12-11Fix mode line inconsistency between normal and insert modesChris Webb
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-11Fix explicit line completionMaxime Coste
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-11Fix parsing nul bytes in regexMaxime Coste
Fixes #4460
2021-12-11Fix spurious warning likely due to String::Data not being std compliantMaxime Coste
2021-12-11Make space a named key to correctly handle shift modifierMaxime Coste
2021-11-25Clang is still unhappy, trying another approach with defining my own conceptMaxime Coste
2021-11-25Avoid using standard conceptsMaxime Coste
Turns out those are unimplemented in clang < 13, use custom code instead.
2021-11-25Templatize parse_quoted to avoid utf8 decoding with ascii delimiterMaxime Coste
2021-11-25small regex impl code style tweakMaxime Coste
2021-11-21Try to fix more CI failures related to C++20Maxime Coste
2021-11-21Fix clang C++20 compilation issuesMaxime Coste
2021-11-21More C++20 refactoringsMaxime Coste
Use CTAD instead of make functions, requires instead of enable_if
2021-11-21Use std::remove_cvref instead of std::decayMaxime Coste
2021-11-21Convert comparisons to spaceship operatorMaxime Coste
2021-11-21Replace std::enable_if with requiresMaxime Coste
Introduce some concepts for enum and flags handling, goodbye and thanks for all the fish std::enable_if.
2021-11-21Micro-optimize regex character class/type matchingMaxime Coste
Also force-inline step_thread as function call overhead has a mesurable impact.
2021-11-21Reduce the amount of Regex VM Instruction codeMaxime Coste
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-21Merge remote-tracking branch 'lenormf/debug_mode-gdb_script'Maxime Coste
2021-11-21Merge branch 'doc_highlighter_switch' of http://github.com/fennewald/kakouneMaxime Coste
2021-11-16Documented -override switch for add-highlighterCarson
2021-11-15Fixes #4432: JSON UI only shows stdin when connecting to an existing sessionSidharth Kshatriya
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-11Recognize both <tab> and <c-i> as forward jumpMaxime Coste
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-08src makefile: Install GDB types in debug modeFrank LENORMAND
2021-11-07Kakoune 2021.11.08Maxime Coste
2021-11-05src highlighters: Factorise docstringsFrank LENORMAND
Fixes #4367.
2021-11-04src highlighters: Sort instantiationsFrank LENORMAND
2021-11-02use shifted key codes on kittyJason Felice
2021-11-02Keep command_fifo read fd open instead of closing/reopeningMaxime Coste
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-02Merge remote-tracking branch 'sidkshatriya/remove-kak-history-file'Maxime Coste
2021-11-02Fix DECRPM parsing for 2026Maxime Coste
As discovered in #4320 the previous code was buggy and would enable synchronized output on any response.