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
42094209fd
Update New flag and last save timestamp on buffer rename
...
Fxies #3244
2019-12-07 15:40:55 +11:00
Maxime Coste
5c5d881c11
Merge remote-tracking branch 'lenormf/reload-buffer-hash'
2019-12-04 21:14:15 +11:00
Frank LENORMAND
e1bd076f5e
src: Reload buffers when their contents' hash changes
...
Instead of triggering a reload event when the timestamp of a buffer's
underlying file changes, do so when its contents are actually modified.
2019-12-03 17:05:24 +01: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
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
Jason Felice
d26bb0ce2b
Add static or const where useful
2019-11-09 12:53:45 -05:00
Maxime Coste
8b2906a14d
Refactor option_to_string quoting support, introduce Quoting::Raw
2019-06-19 23:04:16 +10:00
Delapouite
947e071066
Let parse_lines ensure that there's at least 1 line with \n
2019-04-27 19:29:16 +02:00
Delapouite
0fe8e59abc
Add missing flags to debug buffers output
2019-03-27 19:30:41 +01: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
dfc11d1c43
Refactor Hook management to have a well defined list of hooks
...
Hooks are now an enum class instead of passing strings around.
2018-10-23 08:15:53 +11:00
Maxime Coste
68aba9e353
Use shell specific quoting for env vars
...
Add a test case to validate roundtrips between Kakoune and the
shell.
2018-08-29 07:53:59 +10:00
Maxime Coste
d4e36958f8
Gather options in a vector when running Buffer::on_option_changed
...
on_option_changed might trigger hooks that will mutate the option
managers, invalidating the iterators we use.
2018-05-21 20:07:25 +10:00
Maxime Coste
75eb293f98
Rename Context::Flags::Transient to Context::Flags::Draft
...
Draft is well establish and all draft context are transient.
2018-05-14 08:23:00 +10:00
Maxime Coste
74f90c1fc5
Refactor buffer undo tree
...
Store the undo tree as an array of undo nodes, instead of as a
pointer based tree.
2018-05-02 22:34:55 +10:00
Delapouite
cb02186c77
Make error messages more consistent
2018-04-06 16:56:53 +02:00
Maxime Coste
bfaf52f8c0
Do not jump to buffer start on g.
with no previous modifications
2018-03-13 14:00:57 +11:00
Maxime Coste
9125b01fa8
Detect no-op replaces and do not act on them
...
This avoids recording no-op undo groups.
2018-03-09 23:07:05 +11:00
Maxime Coste
2a60af25dc
Allow l/h to cross line boundaries
...
l and h are now respectively "next character" and "previous character"
2018-02-24 23:16:39 +11:00
Maxime Coste
10c6c59a26
Buffer: avoid expensive option flattening in on_registred with NoHooks
2018-02-18 14:48:24 +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
eeacb8b5a8
Use the _str and _sv string literals more often
2018-01-18 09:00:54 +11:00
Maxime Coste
d45f16b6c8
Buffer: change clamp logic to preserve ordering
...
clamp could change ordering between a coordinate past the end.
Say in a buffer with 1 line of 2 char:
{0, 1} was clamped to {0, 1}
{1, 0} was clamped to {0, 0}
That was reversing their ordering, and might be the root cause
of the bug lurking in undo range computation.
2017-11-07 23:56:24 +08:00
Maxime Coste
e66a5c78ad
Make Buffer::Modification an aggregate
2017-09-01 17:32:03 +07:00
Maxime Coste
ab6a999431
Rename containers.hh to ranges.hh (and Container to Range)
2017-08-29 15:23:03 +07:00
Maxime Coste
fc64369f9d
Purge history on buffer reload when NoUndo flag is on
...
We were preserving the history in that case, so on fifo buffers
(that set the NoUndo flag until the fifo is closed), we still had
the history from the "previous life" of the buffer, leading crashes
when trying to apply it.
Fixes #1518
2017-08-04 11:39:28 +07:00
Maxime Coste
53e1d2f0de
Slight formatting tweak
2017-08-01 14:48:45 +07:00
Maxime Coste
cc946764ed
Consider non-files buffers as never modified
2017-06-28 06:48:24 +01:00
Maxime Coste
475e8849a1
Fix replacing last eol with a single eol
2017-06-26 16:16:46 +01:00
Maxime Coste
fa4b88c2f8
Move tolerance for one past end of line coordinates to highlighter code
...
The rest of Kakoune's code now requires coord passed to Buffer::iterator_at
to be valid.
2017-06-15 17:43:18 +01:00
Maxime Coste
e6c4bed42b
Go back to window lines ending at one past the end of the buffer line
...
Change Buffer::iterator_at so that this case is tolerated, and fixes
the coord to next line start instead of clamping to last line char.
2017-06-15 17:25:37 +01:00
Maxime Coste
208b28cbe7
Simplify a bit buffer iteration functions
...
Dont try to ensure the returned value is valid, incrementing past
the end/decrementing before begin is the caller's error.
2017-06-12 06:10:18 +01:00
Maxime Coste
63a791d651
Fix the Buffer::end() madness
...
Until now, buffer had multiple recognized end coordinates, either
{ line_count, 0 } or { line_count - 1, line[line_count - 1].length }.
Now the only correct end coord is { line_count, 0 }, removing the need
for various special cases.
2017-06-11 12:01:40 +01:00
Maxime Coste
1c0bdd8c85
Run BufCreate hook *before* Buf{Open,New}File
2017-06-07 19:46:43 +01:00
Maxime Coste
21da24235a
Small style tweak
2017-06-07 11:40:13 +01:00
Maxime Coste
f2c0ee62ce
Remove unneeded explicit conversion
2017-05-26 09:51:32 +01:00
Maxime Coste
7ee3039a79
Do not avoid eol in insert mode vertical movement
2017-05-22 17:04:01 +01:00
Maxime Coste
ad9ad7e603
Fix vertical movement with tabstops
...
Fixes #1388
2017-05-21 08:24:44 +01:00
Maxime Coste
5ee21ec932
Respect tabstop in Buffer::offset_coord
2017-05-07 16:26:14 +01:00
Maxime Coste
e722868c60
Fix generation of empty erase changes
...
Fixes #1308
2017-04-20 17:31:27 +01:00
Maxime Coste
ca17572301
Try to fix clang 3.5 compilation
2017-03-22 21:08:52 +00:00
Maxime Coste
e44f95820e
Fixes some clang-tidy warning and add a few missing meta.hh include
2017-03-16 23:34:02 +00:00
Maxime Coste
7d9f1df73a
Small code tweaks regarding flags handling
2017-03-15 18:25:59 +00:00
Maxime Coste
edc2a88643
Rename BufNew and BufOpen hooks to BufNewFile and BufOpenFile
...
Fixes #1225
2017-02-19 13:08:06 +00:00
Maxime Coste
1c63d28f15
Fix Buffer::offset_coord that was dropping the target coordinate
2017-02-07 23:13:14 +00:00
Maxime Coste
472f5149c0
Formatting fix
2017-01-31 21:46:20 +00:00
Maxime Coste
f30e164232
Make SharedString::create take a list of StringViews
2017-01-30 13:38:38 +00:00
Maxime Coste
072064407a
Remove hash from StringData
...
Maintaining the hash value of strings is not worth it as we only
use it for buffer reload, but pay for it on any buffer modifications.
2017-01-28 13:04:55 +00:00
Maxime Coste
69789d4793
When inserting at the end, store the next line as end pos in the change
2017-01-01 16:32:04 +00:00