Commit Graph

4214 Commits

Author SHA1 Message Date
Maxime Coste
f3c19ba7fa Prevent whitespaces in command names
Fixes #1843
2018-02-11 20:35:21 +11:00
Maxime Coste
a822bcd6e0 Do not specify utf8 InvalidPolicy when we are using the default value
It was specified only in two call sites, and everywhere now only uses
the pass policy, which is the default.
2018-02-11 17:39:19 +11:00
Maxime Coste
66fe2d84da Refuse modification of ReadOnly buffers and make Debug buffer readonly
The debug buffer is a bit special as lots of events might mutate it,
permitting it to be modified leads to some buggy behaviour:

For example, `pipe` uses a ForwardChangeTracker to track buffer
changes, but when applied on a debug buffer with the profile flag
on, each shell execution will trigger an additional modification
of the buffer while applying the changes, leading to an assertion
failing as changes might not be happening in a forward way anymore.

Trying to modify a debug buffer will now raise an error immediatly.
2018-02-11 13:06:19 +11:00
Maxime Coste
3584e00d19 Regex: Use a template argument instead of a regular one for "forward"
forward (which controls if we are compling for forward or backward
matching) is always statically known, and compilation will first
compile forward, then backward (if needed), so by having separate
compiled function we get rid of runtime branches.
2018-02-09 22:45:53 +11:00
Maxime Coste
aa9f7753e8 Regex: minor code cleanup 2018-02-09 22:19:56 +11:00
Maxime Coste
cb16e52179 FaceRegistry: pass face names as StringViews instead of const String& 2018-02-09 22:08:29 +11:00
Maxime Coste
e46a5697e5 Add a limit to the size of selection with which we will try to diff on pipe
Limit to 100K of data for now, as we diff at the byte level.
2018-02-09 21:47:18 +11:00
Maxime Coste
bbf62d1779 diff: try to improve code readability 2018-02-09 21:31:10 +11:00
Maxime Coste
b7a3d80bde CommandManager: Use byte rather than columns for token positions
Not only are display columns rarely used to give error positions,
but they make the parsing much slower as for each token we need to
compute the column in the line.
2018-02-09 20:30:33 +11:00
Maxime Coste
e2c1d44a7f Fix parsing of percent tokens with unicode separators 2018-02-06 20:29:08 +11:00
Maxime Coste
4a96926c4b Handle errors while reloading buffer gracefully
Fixes #1831
2018-02-05 20:27:32 +11:00
Maxime Coste
f592768d3a Remove the New flag from a buffer after reloading it
If we reload a buffer, it means its underlying file exists, hence the
New flag does not make sense anymore. It could be that the file appeared
on the filesystem in the meantime.
2018-02-05 20:18:51 +11:00
Maxime Coste
05f57ace07 CommandManager: parse command lines as utf8 instead of ascii
Fixes #1829
2018-02-04 09:21:15 +11:00
Maxime Coste
52016d32bc Makefile: Only check for pkg-config when on a system that uses it
This fixes compilation on OSX where pkg-config is not installed
by default.
2018-02-03 13:37:09 +11:00
Maxime Coste
90c16d2b0d Profile the time it takes to source a file
`:source` command will now generate timings if profile is enabled
in the debug option, to help find which script can be slow to load.

This should help for #1823
2018-02-01 09:03:16 +11:00
Maxime Coste
e41b4ee65d Change m to search until the end of the buffer instead of end of line
Fixes #1774
 # Please enter the commit message for your changes. Lines starting
2018-01-31 11:10:18 +11:00
Maxime Coste
81eb2ee428 Do not strip whitespaces with '*'
Stripping whitespaces there is a failed experiment as it breaks the
ability to use multi-selections consistently: Using '*' followed by some
`N` to add following matches, we end up with mismatched selections
due to whitespace stripping the original selection still contains
whitespaces where all the new ones do not. Once we get to this state,
most selection commands will give different results for the initial
selection and the other ones, breaking predictible multiselection use,
one of the cornerstones of Kakoune editing model.
2018-01-31 09:31:18 +11:00
Maxime Coste
c30a954dfc ncurses: change handling of <c-z> suspend to improve terminal state
reset the mouse state so that the terminal can take back control
of the mouse while Kakoune is suspended, and does not emit focus
events anymore.

Fixes #1816
2018-01-30 10:46:34 +11:00
Maxime Coste
9c25e955df Use '/' register as the default register for <a-k> and <a-K>
Fixes #1808
2018-01-26 14:15:18 +11:00
Maxime Coste
bf73cb0109 Reset normal mode before hiding the reload buffer info box
Reseting normal mode will enable normal mode, which will trigger
a check for buffer modification. We do not want that check to
happen as we are trying to close the info box. Doing that mode
reset first will prevent the check from happening (as the info
box is already displayed), and will correctly hide it afterwards.

Fixes #1809
2018-01-26 13:45:36 +11:00
aver-d
29a7cd3ab4 Insert complete: Remove path info with one buffer
This change is useful when using `set scope completers word=buffer`,
instead of the default word=all.

If candidates all come from the same buffer, then the path/filename
information is the same and therefore unnecessary. This change
prevents the same path from being repeated, and the buffer's
source code is less obscured.

More generally, there could be an option to disable the path
information entirely in all cases, but for now this change seems
a reasonable solution until any such option exists.
2018-01-25 17:49:02 +00:00
Maxime Coste
220be30f02 Support multiline selections in C/<a-C>
Fixes #1725
2018-01-24 10:33:22 +11:00
Maxime Coste
299e22ca7c Do not block when waiting for next event if we have pending input
Handle next event should never block if we have already accumulated
input that we want to process. As we can accumulate new input in
lots of places (everytime we run a shell process for example, we
might end up reading input keys. That can be triggered during the
mode line generation which takes place during display of the window)

Fixes #1804
2018-01-21 12:00:40 +11:00
Maxime Coste
d22c989984 Rename InputModeChange hook to ModeChange
InputModeChange is a bit long to type and its pretty clear in Kakoune
that "Mode" means "Input mode", so use a shorter and as clear name.
2018-01-21 10:34:09 +11:00
Maxime Coste
07dfcd336d Fallback to getpwuid in the unlikely case $HOME is underfined
Add a homedir() helper function, and document the $kak_config
env var.
2018-01-20 11:19:23 +11:00
Maxime Coste
e7cbf38af7 Introduce a $kak_config env var containing the Kakoune user config dir
Makes it easier for users who want to locate their kakrc file, and
does not require to go through shell expansion to get it as
"${XDG_CONFIG_DIR:-${HOME}/.config}/kak"

Fixes #1740
2018-01-19 10:05:08 +11:00
Maxime Coste
55621fb4cc Do not save last command/pipe/regex in register when history is disabled 2018-01-19 09:48:57 +11:00
Maxime Coste
eeacb8b5a8 Use the _str and _sv string literals more often 2018-01-18 09:00:54 +11:00
Maxime Coste
b4f8497f8d Slight code refactor in InputHandler::handle_key 2018-01-15 10:25:58 +11:00
Maxime Coste
e74b581b0a Save/restore main selection from/to strings
Always consider that the first selection in the list is the main
one, save selections that way.

This approach was suggested by PR #1786 but the implementation here
is different, and is used more generally whenever we save selections
to strings.

This is also the prefered way to work only on the main selection:
save selections with Z, reduce to main with <space>, restore with z.

Closes #1786
Fixes #1750
2018-01-12 07:51:19 +11:00
Maxime Coste
2366af29e2 Slight refactor of jump collapsing code 2018-01-12 07:50:52 +11:00
Maxime Coste
827aab1386 Merge remote-tracking branch 'Delapouite/print_status' 2018-01-12 07:03:21 +11:00
Maxime Coste
af4cc11404 Merge remote-tracking branch 'lenormf/fix-makefile' 2018-01-12 07:02:40 +11:00
Delapouite
7ecc3d343f Remove extraneous face when clearing status line 2018-01-11 15:26:42 +01:00
Frank LENORMAND
202c977b3d src makefile: Abort compilation when pkg-config is not in PATH
Fixes #1792
2018-01-11 10:41:19 +03:00
Maxime Coste
bf66302d29 Small code style tweak 2018-01-11 13:57:33 +11:00
Maxime Coste
996d8abef4 Write new buffers even when unmodified
Fixes #1794
2018-01-08 09:42:26 +11:00
Maxime Coste
49e028b847 Add information on InputModeChange hook in the startup message 2017-12-29 10:00:45 +11:00
Maxime Coste
6333ae207f Correctly set the NotBeginOfSubject/NotEndOfSubject flags for regex matching
Fixes #1778
2017-12-29 09:55:53 +11:00
Maxime Coste
6851604546 Regex: Add a RegexExecFlags::NotEndOfSubject flag 2017-12-29 09:55:38 +11:00
Delapouite
74898120ed Add session name filtering for KakBegin hook 2017-12-21 22:22:33 +01:00
Maxime Coste
9b83589b18 Completion: Use a heap to gather the best matches instead of sorting
Generalize the behaviour of `shell-candidates` to insert completion,
gather the best 100 matches by using a heap and poping max a hundred
times.
2017-12-21 12:55:29 +11:00
Maxime Coste
a38d6cc3f0 Highlighter: In general, highlight replaced ranges
Fixes #1251
2017-12-21 12:26:25 +11:00
Maxime Coste
0814bb2962 InputHandler: Preserve no-hooks on insert mode from single command normal mode
Fixes #1775
2017-12-21 10:30:45 +11:00
Maxime Coste
e0b28fa421 Introduce InputModeChange hook
InputModeChange <old mode>:<new mode> is intended to replace the various
<Mode>Begin/<Mode>End hooks.

Fixes #1772
2017-12-18 11:09:54 +11:00
Delapouite
b81c6b5840 Use existing window reference in view mode 2017-12-17 14:42:09 +01:00
Maxime Coste
d8dc7d7f39 Go back to getpwuid call to get user name from user id
Unfortunately, reading /etc/passwd is not enough.
2017-12-15 08:19:56 +11:00
Maxime Coste
cafecda230 Window: avoid positionning window on a negative column
Fixes #1741
2017-12-15 08:17:35 +11:00
Maxime Coste
4b06c09c68 Make edit command work fine when running from an empty context
This way, the kind of context we get from a piped command allows
for opening a buffer and working with it directly.
2017-12-12 18:22:05 +11:00
Maxime Coste
ce2c0e54f4 Detect invalid coordinates in selection_from_string
Fixes #1751
2017-12-12 18:08:40 +11:00