Commit Graph

10096 Commits

Author SHA1 Message Date
razetime
6af78e0f9f Razetime 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-01-14 11:03:52 +05:30
Johannes Altmanninger
4f7d7a5e33 Fix regression when file on command line cannot be opened
Commit 933e4a599 (Load buffer in command line order, 2022-12-06)
introduced a regression: the command

	$ kak /boot/grub/grub.cfg
	Fatal error: no such buffer '/boot/grub/grub.cfg'

quits with no indication of the underlying error.

Prior to 933e4a599, it would open the *scratch* buffer instead,
and show an error in the status line, pointing to the debug buffer,
which would contain:

	error while opening file '/boot/grub/grub.cfg':
	    /boot/grub/grub.cfg: Permission denied

Let's fix this scenario by matching the old behavior.
2023-01-08 17:26:15 +01:00
Johannes Altmanninger
35f23d6fad Remove bogus assertions preventing mouse clicks in insert mode
Recent changes for selection-undo added an assertion that triggers
when a mouse-drag overlaps with an insert mode, because both events
record selection history.  However this is actually fine.  The one
that finishes last concludes the selection edition, while the other
one will be a nop.

The test could be simpler (i.e. not require sleeps) but I figured it
doesn't hurt add this since we don't have any comparable tests.
2023-01-08 10:47:36 +01:00
Adrià Arrufat
f92df3ec96 Add reset to git command docstring 2023-01-06 00:17:38 +09:00
Stacy Harper
8c4b591a9e
Add @packed to hare highlighter
ref: https://todo.sr.ht/~sircmpwn/hare/783
2023-01-02 20:38:12 +01:00
Michał Kruszewski
dddadce7e8 troff filetype: Fix headings highlighting 2022-12-30 21:45:17 +01:00
Johannes Altmanninger
516759bb2f Make selection undo skip over entries that are nop after buffer change
After buffer modification - in particular after deletion - adjacent
selection history entries may correspond to the same effective
selection when applied to the current buffer. This means that we
sometimes need to press <c-h> multiple times to make one visible
change. This is not what the user expects, so let's keep walking the
selection history until we hit an actual change.

Alternatively, we could minimize the selection history after buffer
changes but I think that would make the it worse after content
undo+redo.
2022-12-27 18:24:55 +01:00
Johannes Altmanninger
8427379a5d Tweak selection-undo interaction with WinDisplay hooks
Each selection undo operation is surrounded by pair of
begin_edition()/end_edition() calls.
The original reason for adding these was that in one of my preliminary
versions, a WinDisplay hook could break an undo chain, even if the
hook did not affect selections at all. This has since been fixed.

By surrounding the undo with begin_edition()/end_edition(), try to
ensure that any selection modification that happens in a WinDisplay
hook would not break the undo chain. Essentially this means that,
after using <c-h> to undo a buffer change, this was meant to
make sure that <c-k> could redo that buffer change.

However, it turns out this actually doesn't work.  The attached test
case triggers an assertion.  As described in the first paragraph,
the only real-world motivation for this is gone, so let's simplify
the behavior.
The assertion fix means that we can test the next commit better.
2022-12-27 18:24:55 +01:00
Johannes Altmanninger
8e8c2fb46d Add tests for selection undo 2022-12-27 18:24:55 +01:00
Johannes Altmanninger
016e1be77f Extract variable and add comment in selection change recording
No functional change.
2022-12-27 18:24:55 +01:00
Johannes Altmanninger
02d0584e0f Extract variable in selection undo
No functional change.
2022-12-27 18:24:55 +01:00
Johannes Altmanninger
a50cb5f6e7 Share logic for undo/redo selection changes
I will suggest a few changes to this code.
No functional change.
2022-12-27 18:24:55 +01:00
potatoalienof13
96ddc4cd45 Add a regression test for <a-t> on an 'empty' file. 2022-12-26 09:17:18 -05:00
potatoalienof13
eb447f1c43 Remove a check for inclusivity in select_to_reverse.
It turns out that neither <a-f> or <a-t> make sense when run at the
beginning of the buffer. When I first created the check, I thought
that <a-f> made sense if the character under the cursor was the
character being searched for.  I was wrong, <a-f> should always go
at least one character backwards.
2022-12-26 09:17:06 -05:00
potatoalienof13
7c2d060ec0 potatoalienof13 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.
2022-12-25 17:57:39 -05:00
potatoalienof13
1a4737cd20 <a-t> should not succeed when run on the first character of a file. 2022-12-25 17:57:28 -05:00
potatoalienof13
293d46837d Fix Buffer::advance out of bounds access.
This commit fixes a bug in Buffer::advance where it would first access
m_lines[-1], and then check whether or not that access would have
segfaulted.  This commit moves the check to before the segfault would
occur.
2022-12-22 17:34:42 -05:00
Maxime Coste
c31e53e8a4 Merge remote-tracking branch 'krobelus/fix-cd-after-backspace' 2022-12-22 09:51:58 +11:00
potatoalienof13
041c88c930 This commit attempts to fix a crash with -f. Specifically when kakoune
is run as

> ./kak -f '2oK.k<c-n><ret><c-n>' /dev/null

The crash occurs because when <c-n> is pressed for the second time,
it attempts to use m_completions from the first press of <c-n>.
This only happens when kakoune is run with -f, because when this is done
interactively, there is a client, which means that m_completions gets
reset.  This removes the check that causes that difference.

I am not *completely* sure that this is the best way to solve the
problem, since I am not completely sure why that check was put there
in the first place.
2022-12-21 17:46:49 -05:00
Maxime Coste
938be7a7b0 Merge remote-tracking branch 'krobelus/no-selection-history-in-draft-context' 2022-12-17 10:10:10 +11:00
Răzvan C. Rădulescu
86bd4efd25 Add Python f-string interpolation highlights 2022-12-17 10:08:33 +11:00
Adria Arrufat
80ae73c665 Fix typo for indent key 2022-12-17 10:08:33 +11:00
Maxime Coste
f3201cb956 Speed up expand_unprintable by avoiding BufferIterator
Using BufferIterator adds overhead, but we know that DisplayAtoms
cannot span multiple buffer lines and hence we can directly iterate
using char pointers.
2022-12-15 17:09:37 +11:00
Maxime Coste
20278ed52b Support adding ByteCount to void/char pointers without casting 2022-12-15 13:29:45 +11:00
Maxime Coste
8279a3776f Optimize TabulationHighlighter 2022-12-15 13:17:00 +11:00
Maxime Coste
36d1713b09 Fix a couple bugs with underline highlighting
Add missing curly_underline attribute to json-rpc
Fix underline color not correct after attrbute only change
2022-12-13 12:14:29 +11:00
Johannes Altmanninger
f79580680a Do not record selection history in draft context
Each draft context gets its own private copy of the selections.
Any selection changes will be thrown away when the draft context
is disposed. Since selection-undo is only supported as top-level
command, it can never be used inside a draft context, so let's stop
recording it.
No functional change.
2022-12-10 15:40:19 +01:00
az5112
d099db4ff5 Add a hint about interactive replace 2022-12-08 20:35:57 +01:00
az5112
c4a5e85cc8 az5112 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.
2022-12-08 20:35:57 +01:00
Maxime Coste
a52bb9146e Cleanup expand_unprintable and avoid calling iswprint on base ascii 2022-12-06 17:55:20 +11:00
Maxime Coste
93c50b3cd9 Avoid calculating atom length in DisplayLine::trim_from
Calculating the length of an atom means we need to decode every
codepoint and compute its column width. This can prove quite expensive
in trim_from as we can have full buffer lines, so on buffer with long
lines we might have to go through megabytes of undisplayed data.
2022-12-06 17:51:28 +11:00
Maxime Coste
933e4a599c Load buffer in command line order
Pass the first buffer on the the command line explicitely to client
creation. This ensure the buffer list matches the command line, which
makes buffer-next/buffer-previous a bit more useful.

Fixes #2705
2022-12-06 17:48:42 +11:00
Maxime Coste
e7e46ef76a Fix gas palign2 directive highlight 2022-12-06 17:47:32 +11:00
Maxime Coste
084fc5eb5a Merge remote-tracking branch 'lobre/fix-gopls-def-integration' 2022-12-03 08:41:10 +11:00
Maxime Coste
78c44e94dc Rework StringOps::substr implementation
Avoid iterating over the whole string when the length is not provided
just use the end iterator directly.
2022-12-03 08:24:38 +11:00
Maxime Coste
cd73f2aa17 Use some template magic to automatically deserialize UI messages
We always deserialize arguments in order, and we can extract
argument types from the type of the pointer to method.
2022-11-29 17:19:09 +11:00
Maxime Coste
2688893156 Fix pasting after when selections are overlapping
With overlapping selections, pasting after breaks assumption of
SelectionList::for_each as our changes are no longer happening in
increasing locations.

We hence cannot rely on the ForwardChangeTracker in that case and
have to rely on the more general (and more costly) ranges update logic.

This interacts poorly with paste linewise pastes and we try to preserve
the current behaviour by tracking the last paste position.

Overall, this change really begs for overlapping selections to be
removed, but we will fix them like that for now.

Fixes #4779
2022-11-28 20:27:44 +11:00
Maxime Coste
760a45556c Merge remote-tracking branch '2xsaiko/outgoing/newlines-for-iterm2' 2022-11-21 08:51:21 +11:00
Marco Rebhan
5530f49c14 Deduplicate iterm2 escaping code
This fixes PATH and TMPDIR not being escaped in the iterm-terminal-window and
iterm-terminal-tab commands.
2022-11-20 14:00:34 +01:00
Marco Rebhan
c57805a926 Handle spawning iTerm and screen commands with arguments containing newlines
Before, sed would add quotes to every line of the single multiline argument,
causing the final quoted argument to "split ... command" or screen to contain
unquoted newlines such as this (from kakoune-cr):

	tell application "iTerm"
	    tell current session of current window
	        tell (split vertically with same profile command "env PATH='...' 'sh' '-c' ''
	'    export KAKOUNE_SESSION=$1'
	'    export KAKOUNE_CLIENT=$2'
	'    shift 3'
	''
	'    [ $# = 0 ] && set \"$SHELL\"'
	''
	'    \"sh\"'
	'  ' '--' '51909' 'client0' 'terminal' ") to select
	    end tell
	end tell

Instead of using sed to do this which operates on single lines at a time, simply
use printf to insert ' quotes before and after the entire argument.
2022-11-20 14:00:09 +01:00
Stacy Harper
db93e776c5
Fix hare new line insert indentation after comments
At the moment, inserting a new line while being in a comment result in a
"//<indentation>" instead of "<indentation>//".

To fix this, we just paste the comment and indent after the newline
initial indentation.
2022-11-20 10:39:46 +01:00
Maxime Coste
d1e1f5df32 Merge remote-tracking branch 'Ssamm45/master' 2022-11-20 17:06:12 +11:00
Maxime Coste
5314e2375e Merge branch 'fix/hare-comment-insert' of http://github.com/stacyharper/kakoune 2022-11-20 17:03:14 +11:00
Maxime Coste
d548b0863d Merge branch 'ctags-kak-awk-compatibility' of http://github.com/lobre/kakoune 2022-11-20 17:01:34 +11:00
Maxime Coste
b7b036c210 Change BufferIterator comparison to assert same buffer
Comparing iterators between buffers should never happen, and the
only place we did was with default constructed BufferIterator which
we replace by casting the iterator to bool.

This should improve performance on iterator heavy code.
2022-11-20 16:59:08 +11:00
Marco Rebhan
df12bc8dbd Marco Rebhan 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.
2022-11-20 02:32:32 +01:00
Johannes Altmanninger
a5f684737f Print OS error when ":write -force" fails to change permissions
When the file system runs out of space, "write -force" will fail but
doesn't print "No space left on device".
Let's fix this by including such an underlying error. Untested.

Backstory: I alias "w" to a command that runs "write -force %arg{@}".
so I can overwrite files that already exist outside the editor (I
should probably get used to the new behavior).
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
f69d8c3e12 rc repl tmux: always spawn repl in calling client
Just like the parent commit but for tmux-repl-* commands.

Note that tmux-repl-set-pane without arguments is kind of broken; it
increments the current pane ID, which only works in the most basic
scenarios. We should probably replace it with something better,
with menu completions etc.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
cfea884cf2 rc windowing tmux: always spawn tmux-terminal-window in calling client
The tmux-terminal-window command always spawns windows in the tmux
session where the Kakoune session was started - even if the calling
Kakoune client lives in a different tmux session.

Fix this by always creating the window in the tmux
session of the calling client. We already do the same for
tmux-terminal-{horizontal,vertical}.

I call tmux-terminal-impl with "new-window -a" (instead of
"new-window"), so make sure the fix works for my use case.

I considered retrieving the tmux session ID from the $TMUX environment
variable but the tmux manpage only specifies that $TMUX contains
"some internal data".
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
37dcba9089 rc repl tmux: do not record repl session/window since pane might move
A pane's ID is immutable for the lifetime of the tmux server.
Same with window/session IDs.
When creating a new tmux repl, we record all three IDs to later use
them to send text to the repl.
The window/session IDs can be invalidating when a pane is moved to
a different window/session (via "tmux move-pane", "tmux move-window"
etc). This will cause repl-send-text to fail.
Fix this by dropping the redundant and potentially incorrect
window/session IDs.  The immutable pane ID is enough.
2022-11-19 15:21:38 +01:00