1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-09-11 13:00:41 +03:00
Commit Graph

10216 Commits

Author SHA1 Message Date
Chris Elrod
ed9ecf9abc
Move function before meta so meta applies after function for @foo(ex) pattern, and add Cvoid to types 2024-02-08 17:46:35 -05:00
Maxime Coste
990e92a5f3 Only set Prefix in RankedMatch if the full query matches 2023-11-23 17:16:24 +11:00
Maxime Coste
cad2f6fb66 Bump cirrus llvm to 13 in order to fix OSX builds
Debian stable is on llvm 14 so should be fine.
2023-11-21 21:05:56 +11:00
Maxime Coste
ac7b498c86 Merge remote-tracking branch 'krobelus/changelog' 2023-11-21 21:04:18 +11:00
Maxime Coste
5e4e23289b Fix completion menu not getting hidden on no matches 2023-11-21 17:16:38 +11:00
Johannes Altmanninger
4499b26ca4 Fix use after move in HashMap::insert
Apparently GCC builds worked fine but Clang builds started failing the
"(hash == hash_value(item_key(item)))" assertion.
2023-11-18 19:07:23 +01:00
Johannes Altmanninger
0bb5b28f7e Update changelog 2023-11-17 19:41:55 +01:00
Maxime Coste
296ab1a1ff Improve WordDB performance by precomputing hashes
Avoid multiple computation of string hashes by making it possible
to pre-compute and pass hashes to interned strings and hash maps.
2023-11-17 17:01:51 +11:00
Maxime Coste
b10a935b8c Drop last character for basename matching
If the candidate ends with a slash we still look at the previous
component as the basename.
2023-11-16 12:59:55 +11:00
Maxime Coste
a42aa1e47e Slight cleanup of RankedMatch code 2023-11-15 12:48:23 +11:00
Maxime Coste
1cfe5273f3 Do not use range adaptor to gather ranked matches
This ends up constructing RankedMatch twice, once when computing
the number of elements then once when actually filling the vector.
2023-11-15 12:46:28 +11:00
Maxime Coste
4a1a3ee06e Refactor fuzzy matcher ranking further
Remove FirstCharMatch which does not impact any of the test cases
and explicitely detect paths by using a BaseName flag when we match
the basename of the path.
2023-11-15 12:27:48 +11:00
Maxime Coste
11f0ace9b6 Make shell-script-candidates completer run in the background
Read output from the script as it comes and update the candidate
list progressively.

Disable updating of the list when a completion has been explicitely
selected.
2023-11-14 21:39:03 +11:00
Maxime Coste
719512b308 Use a separate copy of the command completer for each completion
This make the completer lifetime tied to the Prompt mode and removes
the need for the Start flag. It also makes it possible to cleanup
on completer destruction.
2023-11-14 21:39:03 +11:00
Maxime Coste
79f3f5b046 Merge remote-tracking branch 'krobelus/quote-regex-option-value-completions' 2023-11-14 21:38:26 +11:00
Johannes Altmanninger
cac2a32ba2 Fix completion pager not rendering after <a-semicolon> in prompt
Usually, the prompt resets "m_line_changed" after invoking the
change handler:

	if (m_line_changed)
	{
	    m_callback(m_line_editor.line(), PromptEvent::Change, context());
	    m_line_changed = false;
	}

but with

	prompt '' '' -on-change %{ execute-keys <a-semicolon>vl } -shell-script-candidates %{ seq 100 }

the change handler pushes a normal mode with "<a-semicolon>" and then
hands back control to the event loop. Later when the normal mode is
popped we run "Prompt::on_enabled()" but don't actually redraw the
completion pager.
Since the <a-semicolon> excursion by definition did not change our
prompt state, we don't need to recompute completions, only render them.
Do that.

This helps commands that use preview the selected completion via a
"prompt -on-change" handler.
2023-11-14 10:20:08 +01:00
Johannes Altmanninger
118459db59 Quote completions of regex options
Recent changes to `make_error_pattern` added a space to the default
value. This means that

	set g make_error_pattern <tab>

now produces an invalid command because regexes are not quoted.  We do
quote strings; regexes are not all that different so quote them too.
2023-11-13 23:42:39 +01:00
Johannes Altmanninger
70e96c272e Avoid unnecessary copy of completion candidates 2023-11-13 23:42:39 +01:00
Maxime Coste
ed1e2f2e08 Add missing include for std::array 2023-11-13 23:03:03 +11:00
Maxime Coste
fbf387f05c Merge remote-tracking branch 'krobelus/show-grep-errors' 2023-11-13 22:56:10 +11:00
Maxime Coste
c2fb0738d3 Merge remote-tracking branch 'krobelus/fix-noincsearch' 2023-11-13 22:56:06 +11:00
Maxime Coste
c7d887d9d1 Rename stdin/stdout/stderr in Shell a they conflicts with macros
Fixes #5023
2023-11-13 20:19:55 +11:00
Maxime Coste
fc7be678ed Change window_range to emit each element as a separate string 2023-11-13 19:22:33 +11:00
Johannes Altmanninger
14b60ab912 rc grep: include stderr in grep buffer
Running an invalid command like "grep -abc" shows no output at all.
Let's give better feedback by showing the error message from grep.
We used to do this until an unrelated change, bd5955c73 (grep: remove
eventual \r, 2013-02-13).
2023-11-12 11:59:11 +01:00
Johannes Altmanninger
c597a056d0 Fix spurious incremental search when incsearch=false
Regressed in a2c41593a (Fix partial regex text being pushed in history,
2023-11-02).
2023-11-11 14:37:32 +01:00
Maxime Coste
2261b48e35 Fix SingleWord handling in RankedMatch
subsequence_match_smart_case does not necessarily find the word,
but we then check for a contiguous match in which case, if the query
is a word, we also have a single word match.
2023-11-11 18:59:11 +11:00
Maxime Coste
c45a1d435a small code cleanup 2023-11-11 18:46:15 +11:00
Maxime Coste
fbbced5ed0 Support building ArrayView from contigous iterators 2023-11-10 16:35:46 +11:00
Maxime Coste
feeacd8de9 Refactor spawn_shell to return the relevant FDs
This removes the need for the setup_child callback which is quite
tricky as it cannot touch any memory due to vfork, and removes the
Pipe abstraction in favor of a more general UniqueFd one.
2023-11-05 22:47:17 +11:00
Maxime Coste
6babba9bfa Merge remote-tracking branch 'stacyharper/git-log-ret' 2023-11-05 13:49:58 +11:00
Maxime Coste
7a130c89ce Merge remote-tracking branch 'jdugan6240/odin-support' 2023-11-05 13:48:57 +11:00
Maxime Coste
25a00bf2a9 Remove ignored packed attribute and static_assert on Node size
This static_assert is not necessary for the code to work and is
not valid on every platform.
2023-11-05 12:38:39 +11:00
Maxime Coste
0880399fbe Replace snprintf with format_to 2023-11-05 12:30:54 +11:00
Maxime Coste
465e0280d8 Merge remote-tracking branch 'Screwtapello/document-non-recursive-mappings' 2023-11-05 11:25:40 +11:00
Maxime Coste
1da8952e1f Merge remote-tracking branch 'lobre/git-edit' 2023-11-05 11:12:43 +11:00
Maxime Coste
cf6e18e3c1 Merge remote-tracking branch 'krobelus/stop-busy-polling-of-command-socket' 2023-11-05 11:11:02 +11:00
Maxime Coste
c0788f370b Merge remote-tracking branch 'krobelus/patch-selected-lines' 2023-11-05 11:09:41 +11:00
Johannes Altmanninger
b0ddbfc2df Do not poll command sockets while shell command is running
Accepter is a wrapper around a socket watcher. It always uses
EventMode::Urgent, so it will be included in pselect(2) (via
EventManager::handle_next_events()) even while we are waiting for a
(blocking) shell command.  However we will not execute the command
received on this socket until after the shell command is done.

This is implemented with an early return:

	void handle_available_input(EventMode mode)
	{
	    while (not m_reader.ready() and fd_readable(sock))
	        m_reader.read_available(sock);

	    if (mode != EventMode::Normal or not m_reader.ready())
	        return;

so we read available data but don't close the socket.
When using this reproducer

	{
		sleep 1 && echo 'nop' | kak -p session
	} &
	kak -n -s session -e '%sh{sleep 7}'

the first "m_reader.read_available(sock);" will read "nop".  Then
"m_reader.ready()" is true but the socket is still readable. This
means that pselect(2) will return it every time, without blocking.

This means that the shell manager runs a hot loop between pselect(2)
and waitpid(2).

Fix this problem demoting command socket watchers from
EventMode::Urgent. This means that we won't pselect(2) it when handling
only urgent events. Control-C still works, I'm not sure why.

Alternative fix: we could read the commands but then disable the
socket. I tried this but it seems too complex.

Closes #5014
2023-11-04 17:48:25 +01:00
Loric Brevet
83b7bbdc55
rc/tools/git: edit a git indexed file with git edit 2023-11-04 13:43:10 +01:00
Johannes Altmanninger
286dab11d4 rc tools git: "git apply" to apply selections in diffs
This adds a somewhat discoverable frontend for common uses of the
patch command.

Here are some frequently used commands

	# apply selected changes
	git apply 
	# revert selected changes
	git apply -R
	# stage selected changes
	git apply --cached
	# unstage selected changes
	git apply --cached -R
	# apply selected changes and stage them
	git apply --index

For everyday use that's a lot of typing so I recommend adding mappings.
2023-11-04 12:14:48 +01:00
Johannes Altmanninger
8c0424b521 rc tools patch: "patch" command to apply selections in diffs to file
One of the features I miss most from Magit/Fugitive/Tig is to
apply/revert/stage/unstage individual hunks or even exactly the
selected line(s).  This provides a much more convenient way of
splitting changes than "git add/restore -p".

Implement a "patch" command that applies the selected lines within
a diff by piping them to the "patch" program.
It can also feed other programs like "git apply" (see the next commit).

Original discussion: https://discuss.kakoune.com/t/atomic-commits-in-kakoune/1446

Interestingly, :patch is defined outside the "patch" module. This is
to make it readily available for interactive use.
Putting it into the module does not save any work.
I tentatively added a patch module anyway so we can explicitly declare
this dependency.. although there is the argument that this is not
really needed?
2023-11-04 12:14:48 +01:00
Maxime Coste
a8a53cc003 Merge remote-tracking branch 'phaazon/custom-diff-char' 2023-11-04 13:58:09 +11:00
Maxime Coste
0924401c50 Merge branch 'patch-1' of https://github.com/tomsaleeba/kakoune 2023-11-04 11:22:24 +11:00
Tom Saleeba
1e8d2dfe9b
remove "introduced..." fragments 2023-11-04 08:30:29 +11:00
Dimitri Sabadie
27f19fdd91
Rename diff_* into git_diff_*. 2023-11-03 22:04:22 +01:00
Dimitri Sabadie
da2cc1ac3c
Revert adding doc about git_diff_*. 2023-11-03 22:04:22 +01:00
Dimitri Sabadie
8e10822a87
Support setting diff characters in git diffs.
This commit adds `diff_add_char`, `diff_mod_char`, `diff_del_char` and `diff_top_char` as `str` options, with typical
defaults.

This commit also replaces the hard coded +, _, ≃, etc. hardcoded characters in `git update-diff` to use the options from
above.
2023-11-03 22:04:22 +01:00
Dimitri Sabadie
9e4dbdbe6c
Dimitri Sabadie Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2023-11-03 22:04:22 +01:00
Maxime Coste
6a39ac224b Merge remote-tracking branch 'krobelus/fix-quoted-vals-expand' 2023-11-03 21:51:36 +11:00
Maxime Coste
f7499ccf45 Add support for 0-padding in format and replace uses of sprintf 2023-11-03 20:27:41 +11:00