Commit Graph

537 Commits

Author SHA1 Message Date
Sidharth Kshatriya
7c8595c5ee Use grep -E as OpenBSD grep does not like | in regexp otherwise 2021-12-14 15:27:27 +05:30
Maxime Coste
6029ee9815 Fix explicit line completion
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-11 09:34:51 +11:00
Maxime Coste
7648d56fc3 Fix parsing nul bytes in regex
Fixes #4460
2021-12-11 09:01:03 +11:00
Sidharth Kshatriya
9be2a1f170 Remove .kak_history file that seems to have been committed by mistake 2021-11-02 15:28:39 +05:30
Maxime Coste
8299d1da1f Fix pasting all from empty register
Raise an error if the register is empty for paste-all

Fixes #4414
2021-11-01 09:05:57 +11:00
Maxime Coste
05fb07fbc6 Add tests for <a-p>/<a-P>/<a-R> 2021-09-30 20:12:48 +10:00
Maxime Coste
133cb9053a Merge remote-tracking branch 'hugomg/better-lua-indentation' 2021-09-29 20:25:15 +10:00
Hugo Musso Gualandi
25a0fe8f58 lua.kak: Add test cases for unindent 2021-09-26 11:54:43 -03:00
Hugo Musso Gualandi
c26fb65ed1 lua.kak: Add some test cases, and also fix a bug 2021-09-26 11:19:58 -03:00
Frank LENORMAND
e4d6952d8c src: Show a readonly modeline tag when relevant 2021-09-21 12:59:30 +03:00
Maxime Coste
3fc8e29d10 Add support for curly underline and separate underline color
Add support for a third color in face definition that controls
the underline and a 'c' attribute for curly underline (that takes
precedence over 'u' if both are specified)

Allow empty colors to mean default, so that `,,red+u` means the
same as `default,default,red+u`

Fixes #4138
2021-09-07 08:21:26 +10:00
Maxime Coste
40e3614cf4 Prevent overwriting existing file in :write <explicit filename>
Add a -force (equivalent to w!) switch that enables overwriting.
2021-07-20 22:30:41 +10:00
Maxime Coste
be9b2de0ee Only compute command coordinates when necessary
Tracking the line/column of each token takes a surprising big part
of the command parsing logic runtime and is only necessary when we
hit an error.
2021-06-24 17:20:37 +10:00
Maxime Coste
8fdda6d980 Merge remote-tracking branch 'greenfork/improve-elixir-hooks' 2021-06-15 20:48:06 +10:00
Dmitry Matveyev
4e94bf0e41 Event better tests for comments 2021-06-06 14:27:39 +06:00
Dmitry Matveyev
8574c3827a Event better tests for comments 2021-06-06 14:25:06 +06:00
Dmitry Matveyev
0b1654b0cf Better comment inserting tests and fix implementation 2021-06-06 14:13:34 +06:00
Dmitry Matveyev
167cffb3da Better comment inserting tests and fix implementation 2021-06-06 14:08:40 +06:00
Dmitry Matveyev
785f7fe9ed Add more tests for "do" auto-insert 2021-06-06 01:34:09 +06:00
Dmitry Matveyev
8867e40929 Fix elixir copying comment # sign
Elixir uses # for comments, not --.
Implementation is copied from Nim.
2021-06-06 01:32:56 +06:00
Dmitry Matveyev
0f49e7375e Add auto-inserting of "end" keyword to Elixir
fixup! Add auto-inserting of "end" keyword to Elixir
2021-06-06 01:32:53 +06:00
Dmitry Matveyev
fcc04384d1 Fix Ruby <ret> mid-comment
Implementation is copied from Nim.
2021-06-06 00:38:36 +06:00
Dmitry Matveyev
02e625e8fb Remove electric behavior for end keyword
Correctly indentint on "end" keyword seems very hard,
it is simpler to remove it. And we already insert "end"
in ruby-insert-on-new-line hook, so the removal shouldn't
hurt too much.
2021-06-06 00:30:50 +06:00
Dmitry Matveyev
148ad6c1ab Add test for electric indentation in Ruby 2021-06-06 00:27:45 +06:00
Skyler Hawthorne
fb04102fe3 add TODO comment highlighting 2021-05-02 20:38:42 -04:00
Skyler Hawthorne
4bff607758 add tests for rust let statements 2021-05-01 00:46:27 -04:00
Skyler Hawthorne
a25ef2bd6d fix rust pub highlight 2021-05-01 00:35:56 -04:00
Maxime Coste
e04cc1b4c8 Fix rust highlighting tests 2021-04-30 12:41:37 +10:00
Maxime Coste
6f56f02924 Restore previous line-compose test 2021-04-18 16:27:15 +10:00
Tw
41833d7b7d fix line completion with prefix
There's a bug in current line completion, fix it.

Signed-off-by: Tw <tw19881113@gmail.com>
2021-04-11 11:54:48 +08:00
Maxime Coste
5696ed02e4 Fix invalid insertion of ; after } closing some functions
Function taking a parameter with a struct tag on the last line
before the opening { were wrongly treated as structs. Add some
additional regex logic to try to catch those cases.

Fixes #4136
2021-04-08 20:14:02 +10:00
SeerLite
e84dd80244 rc markdown: Fix trailing whitespace removal
Modified the test cases accordingly too
2021-04-01 22:27:30 -03:00
Maxime Coste
835eaf5495 Merge remote-tracking branch 'pickfire/rust-indent' 2021-03-11 07:51:08 +11:00
Ivan Tham
ebe7f82bb2 Support rust visibility for enum and others 2021-03-07 14:22:43 +08:00
Ivan Tham
8df5621334 Support dedent with rust fn qualifiers 2021-03-07 14:12:01 +08:00
Jacob Collins
66787e3b53 Add test for selecting horizontal whitespace 2021-02-25 11:03:18 -05:00
Ivan Tham
4e594e034a Dedent rust await function with ? 2021-02-17 01:17:17 +08:00
Ivan Tham
049591f6b4 Dedent rust empty match 2021-02-17 01:17:14 +08:00
Maxime Coste
978dfe4bdf Fix splitting display line in front of a replaced range
When a replaced buffer range atom was starting exactly at the
location we wanted to split onto the code would split *after*
that atom instead of before.

Fixes #4052
2021-02-16 12:35:25 +11:00
Maxime Coste
fa3aa3c1a3 Add + key to duplicate selections and <a-+> to merge overlapping ones
This is an experiment and might get reverted if overlapping selections
prove too cumbersome.

Fixes #4041
2021-02-15 09:01:14 +11:00
Maxime Coste
841ec2e588 Support a DEBUGGER env-var to run tests
Setting it to `gdbserver :12345` makes it easy to debug a test
case with the correct setup.
2021-01-22 17:21:59 +11:00
Ivan Tham
a955d99fe3 Rust test rename deindent to dedent 2020-12-17 20:08:26 +08:00
Ivan Tham
1965b909e1 Rust dedent after .await 2020-12-17 20:07:44 +08:00
Ivan Tham
ffbdcaa95c Rust handle [ indent like { and ( 2020-12-17 11:19:23 +08:00
Maxime Coste
14f7d2637c Fix test and re-add triple_string support in python highlighting
Triple strings are now distinct from docstrings, triple strings
only preceeded by blanks on the line are considered docstrings.

Avoid highlighting of the closing marker using a lookahead, this
is not fully correct as it will break on a double quote triple
docstring containing a single quote triple string but that seems
improbable enough; if we encounter this in the wild we can split
the two docstring formats into separate regions.
2020-11-23 08:45:59 +11:00
Maxime Coste
13ada43dd9 Merge remote-tracking branch 'Screwtapello/test-doc-updates' 2020-11-22 16:54:09 +11:00
Tim Allen
19115aa524 test: Update the README to describe the current test API.
I removed files which are no longer significant (ui-in, ui-out, selections,
state), added new files which are now important (enabled, script, kak_*),
and reordered the files to reflect the order in which they are applied -
in particular, cmd is applied *after* the input is read.
2020-11-21 16:57:08 +11:00
Andrew Vos
f3f3f80624
Ignore indent when completing lines
When doing line completion, we previously used to not complete the line
if it had different indent to the potential completion.

This commit changes the behaviour to ignore indentation when completing lines.
2020-11-20 20:00:46 +00:00
Maxime Coste
9a5cf2fc9f Support explicit register for :, |, ! and $ commands
Giving an explicit register uses its content for the default value
to use if the user does not enter anything. This enables:

`set-register a %{commands}; execute-keys '"a:<ret>'`
`set-register a %{shell script}; execute-keys '"a|<ret>'`
...

This provides a nice way to avoid the need to escape keys to use
those normal mode commands.

Fixes #3825
2020-10-20 21:56:51 +11:00
Maxime Coste
246a32797a Fix region regexes incorrectly matching ^$ at end of line
Because no flags were set for regex matching, the regex engine was
assuming that the subject string past-the-end matched a end-of-line.
As the subject string already ended with a \n character, the regex
engine processing of the "past-the-end" position would match '^$'
as ^ matched past the existing \n and $ matched the assumed
end-of-line.

Fixes #3799
2020-10-12 12:41:21 +11:00
Ivan Tham
c148fdbe9a Rust always indent after { 2020-10-04 23:40:49 +08:00
Ivan Tham
b0ae30a443 Add missing rust indent after function { 2020-10-04 14:19:33 +08:00
Maxime Coste
fcabffefe1 Merge remote-tracking branch 'pickfire/rust-indent' into master 2020-10-01 19:07:05 +10:00
Ivan Tham
bfca07da4d Rust not to indent on hash 2020-09-30 00:37:35 +08:00
Ivan Tham
df68a77ed2 Rust reindent where to match block 2020-09-28 00:03:53 +08:00
Ivan Tham
785cbaeaed Add rust test for empty line indent 2020-09-27 23:34:08 +08:00
Ivan Tham
5c8dfcdfa9 Rust improve align after partial statement 2020-09-27 15:53:15 +08:00
Ivan Tham
11d98a07dc Rust align open paren for if and for 2020-09-27 15:52:42 +08:00
Simon Fowler
83277d5545 Improve shell indentation implementation.
Use the custom object match command for copying indentation of blocks,
rather than simply increasing/decreasing indentation when start and end
statements are encountered.

This fixes an issue where a newline added after an already correctly
placed `else` or `fi` would trigger an unnecessary deindent. Tests have
been added to ensure no regression in this behaviour.
2020-09-26 22:10:31 +10:00
Maxime Coste
57208a5481 Merge remote-tracking branch 'm-kru/go_kak_fix' into master 2020-09-22 21:18:52 +10:00
Maxime Coste
0ef858da64 Merge remote-tracking branch 'lenormf/fix-3735' into master 2020-09-22 21:17:12 +10:00
Maxime Coste
5d17e1132f Ensure that the capture group actually matched in select_matches
We were creating selections from default constructed iterators,
which happened to have 0,0 coords and led to out-of-order selection
lists.

Fixes #3757
2020-09-22 21:14:40 +10:00
Michał Kruszewski
f78cd6daf8 Improve '}' auto inserting for go language.
Adding "} else if ... {" was not correctly handled.
2020-09-20 12:25:26 +02:00
Frank LENORMAND
d02cb43a88 test: Implement a regression test for #3735 2020-09-18 09:01:32 +03:00
Frank LENORMAND
643bf2bb59 test: Implement a regression test for #3733 2020-09-16 11:00:15 +03:00
Michał Kruszewski
0f63dd339a Provide better support for Go language.
1. Highlight short variable declaration operator :=.
2. 'while' is not go keyword.
3. Auto insert ')', '}', when line ends with '(' or '{'.
2020-09-07 21:48:06 +02:00
Johannes Altmanninger
266fe6f659 Support count argument for [s and ]s
Part of #795
2020-08-02 11:30:14 +02:00
Johannes Altmanninger
98a1afcab0 Support count argument for [p and ]p
Part of #795
2020-08-02 11:30:14 +02:00
Johannes Altmanninger
581f17970d Move tests to accommodate tests with count 2020-08-02 11:30:14 +02:00
Maxime Coste
1c9e460053 Fix escaping of single quotes in rust value highlighting test 2020-07-31 07:55:27 +10:00
Maxime Coste
8d51a99a3b Merge remote-tracking branch 'pickfire/rust-highlight' 2020-07-31 07:50:14 +10:00
John Isom
428232d2fa Add tests for javascript deindenting 2020-07-29 15:05:49 -06:00
John Isom
504d309894 Add go test cases for bad indentation edge case 2020-07-27 12:18:40 -06:00
John Isom
26f4681c3b Add rust test cases for bad indentation edge case 2020-07-27 12:13:23 -06:00
John Isom
2e6e507d42 Add c-family test cases for bad indentation edge case 2020-07-27 12:02:32 -06:00
John Isom
0439128007 Add test cases for go closing brace indentation 2020-07-26 20:28:33 -06:00
John Isom
d2437b468d Add test cases for rust closing brace indentation 2020-07-26 20:03:54 -06:00
John Isom
46ea52a0a8 Add test cases for c-family closing brace indentation 2020-07-26 19:04:08 -06:00
Ivan Tham
974684aa68 Improve rust comment closing handling
/// foo
    ///%( )

    /// foo
    /// %( )

With `c<ret>bar<esc>`,

    /// foo
    bar

    /// foo
    ///
    /// bar

Based on c-family block comment handling, this patch also add rust
block comment indentation.

This affects `o` behavior on empty comment but it allows a way more
efficient way to clear comments.
2020-07-09 23:02:50 +08:00
Ivan Tham
dd6684a17d Split rust comment tests 2020-07-09 00:21:11 +08:00
Ivan Tham
21c38f37cd Fix rust character highlight 2020-07-09 00:21:11 +08:00
Ivan Tham
7bd459f774 Fix rust comment end 2020-07-09 00:21:11 +08:00
Ivan Tham
74e16a0623 Fix rust comment test 2020-07-09 00:21:11 +08:00
Ivan Tham
eac5986323 Fix rust doctest non-hidden macro highlight 2020-07-09 00:21:11 +08:00
Maxime Coste
8abf18209e Fix selections getting unsorted on scroll
Fixes #3478
2020-07-05 10:13:57 +10:00
Maxime Coste
74e3e5efd3 Drain ui-out to avoid deadlock with small pipe buffers 2020-06-10 09:26:32 +10:00
Maxime Coste
66f15cf4ad Fix select wiping captures
It turns out `v = std::move(v)` with v a std::vector is not a no-op,
it clears the vector.
2020-06-07 14:12:54 +10:00
Maxime Coste
d32d185d48 Merge remote-tracking branch 'pickfire/rust-doctests' 2020-06-02 18:44:53 +10:00
Maxime Coste
d43b6799cf Merge remote-tracking branch 'pickfire/rust-dedent' 2020-06-02 18:40:09 +10:00
Ivan Tham
12cafe3ed4 Rust dedent { after where clause 2020-06-02 00:26:47 +08:00
Ivan Tham
b1beea8638 Rust indent after standalone where 2020-05-31 18:13:04 +08:00
Ivan Tham
de4b7f3864 Rust indent block comment 2020-05-31 18:07:17 +08:00
Ivan Tham
4ccb5fd315 Highlight doc tests in rust
Feels a big laggy when system overloaded
2020-05-31 11:47:47 +08:00
Ivan Tham
dd3257e3f2 Rust take indentation before comment to next line 2020-05-30 10:54:55 +08:00
Ivan Tham
7c791f130c Handle dedent in rust syntax
Naively handle dedent after , and ; which works most of the cases but
does not work with multi level dedent.
2020-05-30 10:54:55 +08:00
Maxime Coste
ec4980df34 Merge commit 'krobelus/05-highlight-replace-ranges-crash^' 2020-05-30 09:18:35 +10:00
Maxime Coste
08e0b663f7 Fix unintended interpretation of ranges length syntax
Ranges specified with a +<length> were inconsistent, with +0 meaning
an empty range, while +1 meant a two character long range (first character
+ the following one). Change that to mean a single character.

Fixes #3479
2020-05-29 12:25:57 +10:00
Johannes Altmanninger
61f474fd9d Fix typo in readme 2020-05-28 21:41:21 +02:00
Maxime Coste
109abbeed4 Fix invalid regions with begin > end being generated
Fixes #3495
2020-05-28 20:58:46 +10:00
Johannes Altmanninger
fc63eef695 Fix crash when selecting previous paragraph at buffer begin
Fixes #3489

When there are multiple empty lines between a paragraph and the cursor
(C in the example below), <a-[>p skips over one of them. Prevent the
check for the extra newline from going out of bounds.

```
a paragraph

C	after <a-[>p, the first two lines will be selected
```
2020-05-17 14:15:48 +02:00
Maxime Coste
2104af0771 Fix select_sentence going past the end of the buffer
Fixes #3472
2020-05-10 15:13:15 +10:00
Maxime Coste
954373d3cf Support multi-line replace-ranges
This likely has lots of rough edges, but should be an initial proof
of concept to support folding.
2020-04-27 17:39:21 +10:00
Maxime Coste
65620fb830 Display all failing ui_out in tests instead of just the first one 2020-04-27 17:39:21 +10:00
Maxime Coste
cb119251bc Do not replace partially selected ranges in replace-ranges highlighter
Partially selected ranges should not be replaced to make it possible
to see what is actually selected.
2020-04-27 17:39:21 +10:00
Maxime Coste
0fdfbdfd15 Fix highlighting empty ranges at end of line and begin of line 2020-04-27 14:31:26 +10:00
Maxime Coste
a33b938652 Fix issue with select object and empty matches 2020-04-21 13:21:35 +10:00
Maxime Coste
952aa0ed0a Drop trailing EOL in test commands 2020-04-13 13:36:29 +10:00
Maxime Coste
562ee6143a Parse ascii newline/tab/escape as special keys instead of control keys
Fixes #3439
2020-04-13 12:44:15 +10:00
Maxime Coste
0282cc022e Use %file in the test run script instead of %sh 2020-03-14 13:52:04 +11:00
Maxime Coste
7545fa58ae Fix invalid access to deleted line when updating insert completion
The computation of the completion end position was taking place too
early, before we checked if the buffer did get modified.

Fixes #3349
2020-03-14 13:49:52 +11:00
Maxime Coste
31caae20eb Allow reading from fifo in readonly buffers
readonly is supposed to prevent the user from modifying the buffer
and it can be useful to generate a readonly fifo buffer.

Fixes #3398
2020-03-14 12:58:22 +11:00
Maxime Coste
21dc5284b2 Fix use of non-posix \x printf escape 2020-03-13 09:33:19 +11:00
Maxime Coste
149da2064d Handle invalid utf8 in command line a bit better
Reduce the amount of decoding by working directly on
bytes.

Fixes #3388
2020-03-13 08:02:58 +11:00
Maxime Coste
0a66eb9c47 Expand env vars as list of strings
This makes it possible to do :select `%val{selections_decs}` and to
correctly combine $kak_quoted with those.
2020-03-02 20:53:28 +11:00
Maxime Coste
f808539dea Update inserted range when generating InsertCompletionHide hook param
The buffer might have been mutated in the mean time.

Fixes #3270
2020-01-08 20:33:26 +11:00
Maxime Coste
b37638dda4 Split RegexHighlighters matches per requested buffer ranges
When a region calls the regex highlighter, it is incorrect to share
the regex cache as it means we can get matches that span multiple
regions.

Fixes #3041
2020-01-05 18:58:32 +11:00
Maxime Coste
7470b22c97 Merge remote-tracking branch 'eraserhd/lisp-nested-brackets' 2020-01-05 09:55:37 +11:00
Jason Felice
0ed3bd662c {clojure,lisp}.kak: handle doubled brackets 2020-01-03 15:14:56 -05:00
Maxime Coste
8b6ed26e8c Few style changes on history exposition code 2020-01-02 22:36:26 +11:00
Maxime Coste
43dc494e5c Merge remote-tracking branch 'eraserhd/history-api' 2020-01-02 21:13:43 +11:00
Jason Felice
b03b51d27a Add 'history' and 'uncommitted_modifications' expansions 2020-01-01 19:47:29 -05:00
Maxime Coste
a17a0345cf Fix replacing at begining of buffer
Fixes #3275
2019-12-31 12:49:24 +11:00
Maxime Coste
b68490ef11 Cleanup replaced range selection logic
Do not access Buffer::m_changes to find the inserted range, return
it directly from Buffer::insert and Buffer::replace. This fixes a
wrong behaviour where replacing at eof would lose the selected end
of line (as the implementation does not actually replace that end
of line)
2019-12-18 11:36:17 +11:00
Tim Allen
c7356b363e test: number-lines highlighter now reserves 2 digits by default.
Fixes regression caused by #3261.
2019-12-17 00:57:28 +11:00
Maxime Coste
7b3ab23780 Add a regression test for #3219, which does not seem to fail 2019-11-24 18:11:29 +11:00
Maxime Coste
8528dcd621 Fix test/run ui_out diff display 2019-11-24 18:11:29 +11:00
Maxime Coste
22d9ffa63a Fix crash when deleting buffers in a BufClose hook 2019-11-22 20:29:55 +11:00
Maxime Coste
4d7ea276c4 Use fullwidth latin character in test to try to fix travis 2019-11-18 23:00:19 +11:00
Maxime Coste
25429a905b Try to fix select-display-column test 2019-11-17 10:52:25 +11:00
Maxime Coste
f9d3b0f671 Add select display columns test 2019-11-13 20:13:49 +11:00
Jason Felice
e712138ebd Fix test suite freeze
The issue is that the `test/regression/2056-assert-on-small-window`
sent JSON UI input without waiting for for the JSON UI to be
initialized.

Closes #3196
2019-11-12 09:39:37 -05:00
Maxime Coste
7a8f57f97b Add support for a -codepoint switch to the select command 2019-11-12 21:21:24 +11:00
Jason Felice
5fae16faef Implement %val{selections_char_desc}
Fixes #3194
2019-11-12 20:54:32 +11:00
Jan-Jaap Korpershoek
fcc8ed5df3 [html] Fix indentation when entering a newline while in the middle of a tag
Example:

```
        <tag>|</tag>
```
Then press enter

Old behaviour:
```
        <tag>
            </tag>
```
New behaviour:
```
        <tag>
        </tag>
```

I also added a test for it
2019-11-03 12:25:02 +01:00
Jason Felice
e888f4341c test: Allow expect-style UI tests, testing any var 2019-10-13 14:57:24 -04:00
Jason Felice
2b1ca43328 test: Clear socket correctly when XDG_RUNTIME_DIR is set 2019-10-13 14:56:55 -04:00
Maxime Coste
f1047181cb Fallback to wrapping in between 'word' when 'WORD' fails
First try to break at a whitespace, if that fails (likely because
that last WORD is too long for the wrapping width), then try to
wrap at a 'word' boundary (on a non alphanumeric character).

Fixes #3048
2019-08-12 18:40:56 +10:00
Maxime Coste
1c6aa9baed Fix bug in WrapHighlighter::do_compute_display_setup
Additional lines were not pulled correctly when a line was removed
due to its wrapping hiding the cursor.

Fixes #2999
2019-08-05 20:16:59 +10:00
Maxime Coste
e840140b38 Add indent tests for brace after else indent 2019-07-25 17:27:08 +10:00
Maxime Coste
e42c81c8eb Ensure current context switches away from buffer on delete-buffer
Fixes #3025
2019-07-22 20:26:39 +10:00
Maxime Coste
be3d0f8b33 Filter non-extra_word_chars completion candidates using Codepoints
Fixes #3010
2019-07-09 19:36:57 +10:00
Maxime Coste
9363f98f5b Fix indent/sh/deindent-after-esac test case 2019-07-01 22:04:04 +10:00
Maxime Coste
5c219cc743 Merge remote-tracking branch 'sjjf/sh_indent_v2' 2019-07-01 22:00:31 +10:00
Simon Fowler
c5dd013235 Add tests.
Probably overkill, but at least this is comprehensive . . .
2019-06-30 12:57:59 +10:00
Maxime Coste
e4d6bff5ec Fix quoting of tuple options
Fixes #2990
2019-06-27 22:42:12 +10:00
Maxime Coste
c9858bb6d1 Fix tests with new opt-in quoting 2019-06-23 12:04:21 +10:00
Dmitry Matveyev
01159a9e72 Add support for autoformatting after do keyword in Ruby 2019-06-12 09:03:24 +03:00
Maxime Coste
1ebea85e6f Do not merge selections on backspace in insert mode
Fixes #2861
2019-05-29 23:12:04 +10:00
Maxime Coste
91386a535c Support discarding selections in exec/eval -itersel
Only fail if all selections are discarded.
Fixes #2841
2019-05-13 17:34:43 +10:00
Maxime Coste
229768841b Fix parsing of faces with a base but no attributes 2019-04-28 00:35:52 +01:00