Commit Graph

514 Commits

Author SHA1 Message Date
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
63371da8aa Avoid to_remove vector in select helper function
Remove the need to allocate anything when removing selections.
2020-05-29 12:00:02 +10:00
Maxime Coste
3c265acd6c Remove posB from information given by the diff algorithm
posB is always the sum of previous add len and previous keep len,
so very easy to keep track of.
2020-03-20 20:27:50 +11:00
Maxime Coste
1b28a19058 Merge remote-tracking branch 'Anfid/scroll-test' 2020-03-15 12:32:54 +11:00
Nicolas Ouellet-Payeur
10d887583f Make on_next_key_with_autoinfo() respect idle_timeout
The prompt and autocomplete normally wait for `idle_timeout` before showing
suggestions, however commands like `g`, `v`, or the lead-key show Clippy
instantly.

This fixes the issue by making `on_next_key_with_autoinfo()` wait for
`idle_timeout` before displaying suggestions.

Fixes mawww/kakoune#3365
Fixes mawww/kakoune#2066
2020-02-27 10:36:15 -05:00
geppettodivacin
39a2ab84fa Use ReverseView to perform fewer allocations
The first attempt at a bug fix for @ symbols in selection buffer names
worked, but it was very inefficient. In particular, it allocated three
different vectors, and we really only needed the correct elements.
Manipulating iterators to give us the right slices of the existing
vector is far more efficient.

By reversing the original content and taking the last two, we're able to
get the number of selections and main selection without too much hassle.
The buffer name is everything from the start of the content to the
selection count. This gets us through with only one vector allocation.

Credit to @mawww for the optimization idea and for fixing my types.
2020-02-02 22:12:18 -06:00
geppettodivacin
5596b4b2b9 Add support for @ symbols in selection buffer
The selection descriptions use the format
`<buffer>@<timestamp>@<main_index>`. This fails when file paths have `@`
symbols in them: the parser splits on `@` symbols and finds more values
than it expects.

We here modify the behavior to require *at least* two @ symbols, using
the last two for `<timestamp>` and `<main_index>` and leaving the
remaining text for the <buffer>. This should work for any number of `@`
symbols, since `<timestamp>` and `<main_index>` are numbers and should
never contain `@` symbols.
2020-01-26 16:03:03 -06: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
Maxime Coste
874717885a Code style tweak in insert_output 2019-12-14 09:20:01 +11:00
Maxime Coste
32157a5809 Merge remote-tracking branch 'lenormf/reevaluate-exclamation-point' 2019-12-14 09:13:43 +11:00
Maxime Coste
4fdbf21ff8 Refactor diff to make allocating a diff vector optional
The diff interface now goes through a for_each_diff function that
uses a callback for each found diff.
2019-11-30 11:29:36 +11:00
Mikhail Pogretskiy
89b4996fd7 Update scroll behavior 2019-11-28 22:35:52 +07:00
Frank LENORMAND
7512f5eae6 src: Use begin() to get iterators
When compiling the code with `-Wp,-D_GLIBCXX_ASSERTIONS`, the process
gets aborted, likely because iterators to standard containers are
not obtained in a safe way.

Fixes #3226.
2019-11-25 11:34:39 +01:00
Maxime Coste
a7d3976a10 Fix typo 2019-11-13 08:58:15 +11:00
Maxime Coste
e964b68ab8 Add support for selecting and exporting selections in display columns
Fixes #2724
2019-11-12 21:56:45 +11:00
Maxime Coste
7a8f57f97b Add support for a -codepoint switch to the select command 2019-11-12 21:21:24 +11:00
Maxime Coste
5060a4733a Add mode information to next-key mode name
Currently expose an additional name, the format is up for
discussion.

Fixes #1855
Fixes #2569
Fixes #2672
2019-11-11 21:47:47 +11:00
Jason Felice
d26bb0ce2b Add static or const where useful 2019-11-09 12:53:45 -05:00
Jason Felice
c9fce9f83d Merge selection list parsing into selection_list_from_strings 2019-11-07 14:51:04 -05:00
Maxime Coste
3c34de7fe7 Remove explicit sizes from make_array calls 2019-10-17 22:48:22 +11:00
Delapouite
2148b84274 Add unambiguous titles for infobox "enter combining operator"
fix #3089
2019-10-10 08:34:36 +02:00
Maxime Coste
fc3a1b6973 Make arrow keys normal mode mappings instead of commands 2019-09-15 19:40:38 +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
b18ca12882 More functional style for '*' code 2019-07-21 12:14:25 +10:00
Frank LENORMAND
b040bf8b81 src: Use all selections to generate a pattern upon hitting *
This commit makes the `*` and <a-*> primitives compose a search pattern
comprised of all the current selections, as opposed to only the main one.

All selections are OR'd into the default search register, which makes it
convenient to search for several identifiers already selected.

To retain the old behaviour, the following mappings can be used:

```
map global normal * ': exec -draft -save-regs "" %{<space>*}<ret>'
map global normal <a-*> ': exec -draft -save-regs "" %{<space><a-*>}<ret>'
```

Fixes #2994
2019-07-01 19:53:08 +03:00
Maxime Coste
469818c6f9 Tweak history restoring behaviour 2019-06-23 12:05:09 +10:00
Maxime Coste
e613292568 Use register to store prompt history 2019-06-23 12:05:09 +10:00
Maxime Coste
8b2906a14d Refactor option_to_string quoting support, introduce Quoting::Raw 2019-06-19 23:04:16 +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
525684f4da Make keymap fully constexpr 2019-03-16 11:54:56 +11:00
Jason Felice
7cf6eddc30 Add object mode expansions 2019-02-17 20:18:19 -05:00
Jason Felice
000aa2282c Add object command 2019-02-14 09:32:04 -05:00
Maxime Coste
4cb402ac1a Remove references to SelectionList from selectors 2019-02-04 12:52:55 +11:00
Maxime Coste
7f9fe32f2d Remove target_eol and small code cleanups 2019-02-04 12:52:48 +11:00
Maxime Coste
36e9e7eaf9 Change pipe diffing to work linewise
This should greatly improve performances as we only need to diff
lines instead of individual characters.

Closes #2678
Fixes #2037
2019-01-23 20:20:54 +11:00
Maxime Coste
370d10ccc7 Always select inserted text after piping
Relying on general selection update code is error prone due to
diffing.

Fixes #2394
2019-01-23 20:14:08 +11:00
Maxime Coste
fd043435e5 Split compile time regex flags from runtime ones 2019-01-20 22:59:28 +11:00
Maxime Coste
0e1e0fc57b Improve deindent behaviour with mixed indent 2018-12-13 17:35:16 +11:00
Maxime Coste
e0b9327a9f Merge remote-tracking branch 'lenormf/fix-trim-selections' 2018-11-27 18:25:14 +11:00
Maxime Coste
1553d91d27 Make '_' the default extra_word_chars, and remove built-in support
Fixes #2599
2018-11-27 18:16:21 +11:00
Delapouite
ec0926c312 Change next_key title for <a-f>, <a-t>, <a-F> and <a-T> 2018-10-23 19:09:01 +02:00
Frank LENORMAND
2d44712766 src: Implement <a-m> and <a-M>
Closes #2425
2018-09-30 19:56:37 +03:00
Frank LENORMAND
6b7200e4d5 src: Move <a-m> to <a-_> 2018-09-30 19:45:20 +03:00
Frank LENORMAND
3d79107773 src: Drop selections that only contain whitespace on _
Fixes #2387
2018-09-27 14:47:26 +03:00
Maxime Coste
7cf3cbde8e Cleanup some trailing whitespaces and double semicolon 2018-07-26 21:56:34 +10:00
Maxime Coste
737807dde2 Replace a few loops with ranges 2018-07-26 21:23:06 +10:00
Maxime Coste
5f825cf0f5 Merge remote-tracking branch 'lenormf/fix-C-skip-empty-lines' 2018-07-23 21:14:23 +10:00
Maxime Coste
124a5d4905 Tolerate restoring invalid coordinates from register
Clamp those selection after updating them to the current timestamp

Fixes #2078
2018-07-05 07:54:28 +10:00
Maxime Coste
d6c6ed9bbf Store each selection as a separate element in a register
It makes more sense to use the list nature of the register to store
the selections instead of storing them as a single string separated
by spaces.
2018-07-05 07:54:28 +10:00
Maxime Coste
183f32803b Fix selection save/restore from registers post selection list syntax change 2018-07-05 07:54:28 +10:00