Commit Graph

10275 Commits

Author SHA1 Message Date
Johannes Altmanninger
20b0eadfc8 Don't modify prompt history when validating empty input
Fixes #5076
2024-01-15 15:08:10 +01:00
Johannes Altmanninger
9d8c9777a4 Await all UI events after each key press in mouse-during-insert test
This test doesn't care about testing things like "if I send the next
key before we have finished reacting to the previous ones, nothing
bad ever happens".

Hence we can until exhaustion after each input.  This should fix
bespoke flakiness. The handling of "c<esc>" should be atomic.

This reasoning probably applies to most tests; waiting for all events
seems like the safest and easiest approach overall (compared to sleep
or sleep-until). The downside is that the tests need changes when
UI code changes but it rarely does, and if it does we can automate
the updates.

Closes #5073
2024-01-15 15:08:10 +01:00
Johannes Altmanninger
ea930664ad rc tools git: fix off-by-one regression in git blame SHA column
Introduced in f27f6fa2d (rc git: fix "git blame" on macOS with perl
rewrite, 2023-11-12); awk uses 1-based indices but perl uses offsets.
2024-01-07 20:51:20 +01:00
Maxime Coste
9b166e8007 Try to fix regression/0-mouse-during-insert test flakyness 2024-01-05 15:39:30 +11:00
Maxime Coste
9716875ba9 Merge remote-tracking branch 'arachsys/scheme-infnan' 2024-01-05 15:27:25 +11:00
Maxime Coste
12246674f1 Merge remote-tracking branch 'arachsys/groovy-quoting' 2024-01-05 15:26:44 +11:00
Maxime Coste
91d6ac013f Merge remote-tracking branch 'krobelus/fix-with-option' 2024-01-05 15:25:51 +11:00
Maxime Coste
eed3aa24c1 Merge branch 'patch-1' of https://github.com/igor-ramazanov/kakoune 2024-01-05 15:21:57 +11:00
Maxime Coste
c33d7f84d6 Merge branch 'patch-1' of http://github.com/yatesco/kakoune 2024-01-05 15:17:27 +11:00
Igor Ramazanov
1edebb8505
Update scala.kak to support SBT, ScalaCLI and Ammonite files
* https://www.scala-sbt.org/1.x/docs/Directories.html#sbt+build+definition+files
* https://scala-cli.virtuslab.org/docs/getting_started#scripting
* https://ammonite.io/#ScriptFiles
2023-12-30 19:29:32 +00:00
Maxime Coste
43e8aadcaa Fix performance of diff-based reloading of buffers
It turns out diffing was pretty fast, but applying the diff was
sub-optimal as it was constantly inserting/erasing lines which
led to lots of unnecessary shifting. Fix this by manually tracking
a read/write iterator and only shifting when necessary (on keeps,
and inserts).
2023-12-26 21:21:01 +11:00
Maxime Coste
68e73d8a24 Take eq predicate by reference in for_each_diff 2023-12-26 21:21:01 +11:00
Maxime Coste
3c81a4a253 Small code style tweak 2023-12-26 18:49:16 +11:00
Maxime Coste
ba7059a2dc Fix wrong name 2023-12-26 18:09:25 +11:00
Colin Yates
f8ad2e3726
Update TRAMPOLINE
added missing word "...which *does* not store anything written..."
2023-12-20 15:47:28 +00:00
Johannes Altmanninger
1ce639f2f9 rc windowing: with-option to restore option value also after error
Today "with-option foo bar command-that-fails" fails with

	Error: 1:1: 'evaluate-commands': 1:1: 'with-option': 2:5: 'evaluate-commands': 4:9: 'evaluate-commands': 1:2: 'no-such-command': no such command

but leaks the option value. Fix this by resetting the option and
rethrowing the error.  Unfortunately the original stack trace is lost
(questionable behavior inherited from C++?).
2023-12-16 12:13:20 +01:00
Chris Webb
d9614c77e1 Fix quoting in rc/filetype/groovy.kak
Escape " with \ inside a double-quoted string to avoid a load error.
2023-12-13 17:22:54 +00:00
Chris Webb
51dab20aef Fix escaping in the scheme.kak highlighter awk script
The awk-generated highlighters in scheme.kak need '\\.' to obtain '\.'
in the generated kakscript output. Fix the inf/nan rule (which should
generate '(?:inf|nan)\.0') to read '(?:inf|nan)\\.0' in the awk.
2023-12-13 17:12:59 +00:00
Maxime Coste
83fb65aef5 Merge remote-tracking branch 'krobelus/generalize-windowing' 2023-12-12 21:29:31 +11:00
Maxime Coste
533f51c744 Merge remote-tracking branch 'krobelus/prefer-input-order-over-alphabet' 2023-12-12 21:27:31 +11:00
Maxime Coste
96b74d1ad6 Merge remote-tracking branch 'arachsys/hide-unmapped' 2023-12-12 21:24:47 +11:00
Maxime Coste
9cc9374375 Merge remote-tracking branch 'lobre/pl-not-executable' 2023-12-12 21:24:10 +11:00
Maxime Coste
065e0229a9 Fix stray semicolon 2023-12-12 21:23:57 +11:00
Maxime Coste
250ead2b7a Merge remote-tracking branch 'arachsys/c-family-pp' 2023-12-12 21:21:40 +11:00
Maxime Coste
fda67a7b08 Merge remote-tracking branch 'arachsys/mail-highlight' 2023-12-12 21:20:32 +11:00
Maxime Coste
5ed2433b9f Merge remote-tracking branch 'arachsys/unsigned-char' 2023-12-12 21:19:52 +11:00
Chris Webb
86979841b7 Improve c-family highlighting of preprocessor directives
The current handling of preprocessor directives in filetype/c-family.kak
leads to a wall of solid colour for more complicated #if or #define
directives, although #include is already nicely highlighted.

Instead of highlighting an entire directive with the meta face, highlight
just the #define, #if or #elif keyword as meta, treating the rest of the
directive as normal c-family expressions. This significantly improves
the readability of complex macro definitions.

For directives other than #define, #if and #elif, we treat the rest of
the directive as an opaque string in normal face rather than trying to
highlight it, covering cases like #error, #pragma, etc. where the rest
of the line is an error message string or other non-expression content.

This does the right thing for #ifdef and #ifndef too, as we don't highlight
identifiers in c-family text so their arguments should be normal face
anyway.
2023-12-10 13:50:29 +00:00
Chris Webb
8a14fbc15b Highlight inline patches and signatures in mail.kak
We already pull in the diff module in mail.kak to enable the nice
:diff-jump behaviour on inline patches. Also enable the shared/diff/
highlighter underneath our shared/mail/ highlighter for inline diffs,
listing it first so mail patterns take precedence over diff patterns.

De-emphasise signatures including the standard '^-- \n' separator in the
same way as quoted text in a reply.

Fixes: https://github.com/mawww/kakoune/issues/4998
2023-12-10 11:42:32 +00:00
Chris Webb
a8d5b8bd2c Fix compiler warnings when char is unsigned
In several places, we check for a control character with something like

  char c;
  [...]
  if (c >= 0 and c <= 0x1F)
    [...]

When char is signed (e.g. amd64) this is fine, but when char is unsigned
by default (e.g. arm32 and arm64) this generates warnings about the
tautologous check that an unsigned value is non-negative.

Write as

  if ((unsigned char) c <= 0x1F)
    [...]

which is both correct and not suspicious under both conventions.
2023-12-10 11:09:55 +00:00
Chris Webb
7b2772ef89 Change use of deprecated '->' operator on an iterator
In display_buffer.hh, the '->' operator is used on an iterator, but
(surprisingly) this is deprecated from C++20 because of x-value vs
l-value ambiguity. Now clang's -Wdeprecated-declarations warns about it
as we declare -std=c++2a. See

  https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1252r2.pdf

which was adopted for 2019-03.
2023-12-10 10:58:42 +00:00
Chris Webb
ee8c74c724 Add -Wno-stringop-overflow for g++
g++ 13.x is confused by the reinterpret_cast in Kakoune's memory.hh
allocator. Use -Wno-stringop-overflow to silence a large number of
verbose false alarms.
2023-12-10 10:26:37 +00:00
Chris Webb
a90d1d33f7 Mark refresh_ifn() implementation as an override in input_handler.cc
This was spotted by clang's -Winconsistent-missing-override in -Wall.
2023-12-10 09:58:40 +00:00
Chris Webb
7af2b99317 Hide empty and undocumented mappings from autoinfo
Users who rebind default keys and unmap the originals by binding them
to empty strings with empty docstrings end up with empty lines in the
autoinfo. For example, https://github.com/mawww/kakoune/issues/4918.

Hide completely null bindings which have both an empty mapping and an
empty docstring in the autoinfo, as an easy mechanism for these users to
eliminate the UI noise.

Fixes https://github.com/mawww/kakoune/issues/4918
2023-12-06 17:35:46 +00:00
Loric Brevet
a362c8a145
Perl files are not always executable 2023-12-04 14:19:15 +01:00
Maxime Coste
7f49395cf9 Fix basename prefix flag to use smartcase eq 2023-12-04 19:22:32 +11:00
Johannes Altmanninger
658c3385a9 ranked match: prefer input order over alphabetical order for user-specified completions
When using either of

	set-option g completers option=my_option
	prompt -shell-script-candidates ...

While the search text is empty, the completions will be sorted
alphabetically.
This is bad because it means the most important entries are not listed
first, making them harder to select or even spot.

Let's apply input order before resorting to sorting alphabetically.

In theory there is a more elegant solution: sort candidates (except
if they're user input) before passing them to RankedMatch, and then
always use stable sort. However that doesn't work because we use a
heap which doesn't support stable sort.

Closes #1709, #4813
2023-12-02 10:43:59 +01:00
Johannes Altmanninger
d6215dc25d Reuse for_n_best when sorting values from complete options
While at it, remove a needless reserve() call and reserve an extra slot
because "InsertCompleter::try_complete" might add one more element.
2023-12-02 09:57:15 +01:00
Maxime Coste
84ecd41da1 Merge remote-tracking branch 'herrhotzenplotz/feat/hg-highlight-keywords' 2023-12-02 11:05:27 +11:00
Maxime Coste
94d58b2e07 Merge remote-tracking branch 'sidkshatriya/escape-curly-bracket' 2023-12-02 11:03:56 +11:00
Maxime Coste
c93c57a46f Merge remote-tracking branch 'krobelus/fuzzy-menu' 2023-12-02 10:56:29 +11:00
Maxime Coste
42fefb16af Merge remote-tracking branch 'arachsys/write-replace' 2023-12-02 10:56:11 +11:00
Maxime Coste
8e2eacae83 Merge remote-tracking branch 'krobelus/fix-git-blame' 2023-12-02 10:48:49 +11:00
Maxime Coste
215aa0b2fb Fix single word detection when query is not single word 2023-12-02 10:39:23 +11:00
Maxime Coste
5b1da70adc Merge remote-tracking branch 'm-kru/troff' 2023-12-02 10:08:16 +11:00
Chris Webb
3ba3399f94 Set replacement file permissions before moving into place
When doing :write -method replace, make sure we've set the correct mode,
uid and gid on the replacement file before attempting to rename it on
top of the original. This means that the original file is left in place
with correct permissions if anything fails, rather than ending up with
0700 permissions from mkstemp().
2023-11-28 08:51:32 +00:00
Chris Webb
d3af9b57d4 Restore file ownership when editing with root privilege
When a privileged :write is used with -method replace, it silently resets
the ownership of files to root:root. Restore the original owner and group
in the same way we restore the original permissions. Ownership needs to
be restored before permissions to avoid setuid and setgid bits being set
while the file is still owned by root, and to avoid them being subsequently
lost again on chmod(2).
2023-11-26 18:12:52 +00:00
Chris Webb
05bbdb27c9 Fix crash when ':write -method replace' fails to create tempfile
If a user attempts to save a file without write permission for the
containing directory, with writemethod set as 'replace' or an explicit
':write -method replace' command, kak crashes with "terminating due to
uncaught exception of type Kakoune:runtime_error". (Note this doesn't
happen with a forced write, which fails earlier when it tries to enable
u+w permission.)

Don't raise another exception when already bailing out with a runtime
error for failing to create a temporary file or open the existing file.
Instead, make a best-efforts attempt to restore the file permissions
before raising the first exception, and only report the runtime chmod
exception if that step fails on the non-error path.
2023-11-26 17:50:32 +00:00
Michał Kruszewski
7910aff11d troff: Highlight .pdfhref and links 2023-11-25 19:45:20 +01:00
Chris Webb
32680e5d65 Skip output synchronization query when explicitly disabled
Some terminals misbehave when queried for output synchronization support,
such as Windows Terminal as reported in

  https://github.com/mawww/kakoune/issues/5032

The relatively long response from a terminal which does support output-sync
is also prone to getting torn over a slow link such as a serial console,
causing stray input to the editor.

In ui_options, the terminal_synchronized option controls the use of this
feature, but unfortunately the query is unconditionally sent at startup
even when this is set false.

Skip the query at startup when terminal_synchronized is explicitly false.

We query at most once per terminal in set_ui_options so the behaviour
is correct both when kakoune is started with terminal_synchronized unset
and when it is started with terminal_synchronized set false but this is
later unset.
2023-11-24 12:55:45 +00:00
Maxime Coste
990e92a5f3 Only set Prefix in RankedMatch if the full query matches 2023-11-23 17:16:24 +11:00