summaryrefslogtreecommitdiff
path: root/src/context.hh
AgeCommit message (Collapse)Author
2025-03-24Fix prompt history recording when using mapped keysJohannes Altmanninger
Commit e3122ab2c (Refactor prompt history handling, 2023-07-05) was a nice simplification but it breaks a rare edge case. It suppresses history recording if all keys the prompt receives were synthesized. That's not quite the right criteria: it means that if prompt is created, edited and and executed, all via mapped keys, we fail to add to history. The criteria should rather be something like "if all keys the prompt receives came from synthesized events". Make it so. This allows us to get rid of the "noninteractive" nested bool that was only used for disabling history.
2024-08-16include headers cleanupAdrià Arrufat
2024-08-12Reduce exposed headers from context.hhMaxime Coste
2024-04-27Don't capture local-scoped faces in promptJohannes Altmanninger
ASan shows that we resolve a face spec owned by a freed stack variable. ================================================================= ==2263300==ERROR: AddressSanitizer: stack-use-after-return on address 0x7a9316c33918 at pc 0x633ea421d8ea bp 0x7ffca001e980 sp 0x7ffca001e970 READ of size 8 at 0x7a9316c33918 thread T0 ... #6 0x633ea421d8e9 in Kakoune::FaceRegistry::resolve_spec(Kakoune::FaceSpec const&) const src/face_registry.cc:128 ... Address 0x7a9316c33918 is located in stack of thread T0 at offset 2328 in frame #0 0x633ea427a095 in operator() src/commands.cc:2267 This frame has 26 object(s): [32, 36) '<unknown>' ... [544, 560) 'disable_hooks' (line 2269) ... [928, 2432) 'local_scope' (line 2271) <== Memory access at offset 2328 is inside this variable
2024-04-12Introduce "local" scope in evaluate-commandsMaxime Coste
When using `eval` a new scope named 'local' gets pushed for the whole evaluation, this makes it possible to temporarily set an option/hook/alias... Local scopes nest so nested evals do work as expected. Remove the now trivial with-option command
2024-03-27Add ClientRenamed hookTobias Pisani
2023-10-25Default comparison operators that can beMaxime Coste
2023-10-25Remove redundant comparison operatorsMaxime Coste
Since C++20 (a != b) get automatically rewritten as !(a == b) if the != operator does not exist.
2023-09-02Do not make cursor visible after mouse scrolling and view commandsMaxime Coste
ensure cursor is visible after user input except if the command implementation opted-out. Hooks and timers should not enforce visible cursor. PageUp/PageDown and `<c-f>` / `<c-b>` commands still move the cursor as this seemed a desired behaviour.
2023-08-23Revert "Only make cursor visible after buffer or selection change"Maxime Coste
This is currently broken on various corner cases and breaks the "master branch should be good for day to day work" implicit rule, ongoing work to stabilize this feature will take place on the no-cursor-move-on-scroll branch until its deemed ready. This reverts commit 1e38045d702ec6eb2425016d9b02636270ab1b1e. Closes #4963
2023-08-16Only make cursor visible after buffer or selection changeMaxime Coste
Kakoune now does not touch cursors when scrolling. It checks if either the buffer or selections has been modified since last redraw. Fixes #4124 Fixes #2844
2023-06-17Rename "disable_history" stack state to "noninteractive"Johannes Altmanninger
The commit after next will fix a bug where we wrongly disable prompt history in some scenarios. The root cause is that life span of "disable_history" does not model when we actually want to disable history. Let's rename the state variable to "noninteractive". It's set whenever we are executing a hook, mapping or command. Note that it's also active inside ":prompt"'s callback, which doesn't play well with the new name :(
2023-01-28Merge remote-tracking branch ↵Maxime Coste
'krobelus/selection-undo-fix-standstill-after-buffer-change'
2023-01-08Remove bogus assertions preventing mouse clicks in insert modeJohannes Altmanninger
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.
2022-12-27Share logic for undo/redo selection changesJohannes Altmanninger
I will suggest a few changes to this code. No functional change.
2022-12-10Do not record selection history in draft contextJohannes Altmanninger
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-09-02Allow to undo and redo selection changesJohannes Altmanninger
From the issue: > It often happens to me that I carefully craft a selection with multiple > cursors, ready to make changes elegantly, only to completely mess it > up by pressing a wrong key (by merging the cursors for example). Being > able to undo the last selection change (even if only until the previous > buffer change) would make this much less painful. Fix this by recording selection changes and allowing simple linear undo/redo of selection changes. The preliminary key bindings are <c-h> and <c-k>. Here are some other vacant normal mode keys I considered X Y <backspace> <minus> # ^ = <plus> ' unfortunately none of them is super convenient to type. Maybe we can kick out some other normal mode command? --- This feature has some overlap with the jump list (<c-o>/<c-i>) and with undo (u) but each of the three features have their moment. Currently there's no special integration with either peer feature; the three histories are completely independent. In future we might want to synchronize them so we can implement Sublime Text's "Soft undo" feature. Note that it is possible to restore selections that predate a buffer modification. Depending on the buffer modification, the selections might look different of course. (When trying to apply an old buffer's selection to the new buffer, Kakoune computes a diff of the buffers and updates the selection accordingly. This works quite well for many practical examples.) This makes us record the full history of all selections for each client. This seems wasteful, we could set a limit. I don't expect excessive memory usage in practice (we also keep the full history of buffer changes) but I could be wrong. Closes #898
2022-09-02Prepare to record selection changes as perceived by the userJohannes Altmanninger
To be able to undo selection changes, we want to record selections from all commands that modify selections. Each such command will get its own private copy of the selections object. This copy will live until the command is finished executing. All child commands that are run while the command is executing, will also use the same copy, because to the user it's all just one selection change anyway. Add an RAII object in all places where we might modify selections. The next commit will use this to create the private selections copy in the constructor (if there is none) and remove redundant history items in the destructor. We could avoid the RAII object in some places but that seems worse. For lifetimes that don't correspond to a lexical scope, we use a std::unique_ptr. For lambdas that require conversion to std::function, we use std::shared_ptr because we need something that's copyable.
2022-08-29Access selections via helper methodsJohannes Altmanninger
The next commit changes the selections to a history of selections. Today we directly access the selections data member. Let's instead use an accessor method, to reduce the number of changes in the next commit.
2021-10-06src: Allow `ga` to skip removed buffersFrank LENORMAND
This commit prevents `ga` from returning a “no last buffer” error when the previously displayed buffer was removed. Since the jumps list keeps track of the order in which buffers were displayed already, handling arbitrary `delete-buffer`s as well, cycle through it to implement `ga` instead of storing a pointer. Note that this commit doesn't take into account buffer flags that might exclude some buffers from being cycled over by commands. Fixes #1840
2019-07-22Ensure current context switches away from buffer on delete-bufferMaxime Coste
Fixes #3025
2019-02-17Collapse jumps based on current index changeMaxime Coste
The previous method, while likely more correct, could restore jump lists containing references to already removed buffers.
2019-01-24Header and dependency cleanupMaxime Coste
2018-09-12Only commit undo groups when buffer was modifiedMaxime Coste
This fixes an interaction with kak-lsp that would trigger undo group commit when setting a buffer option value.
2018-07-25Fix uninitialized context flagsMaxime Coste
2018-07-05Do not reparse %sh{...} stringsMaxime Coste
Automatic reparsing of %sh{...}, while convenient in many cases, can be surprising as well, and can lead to security problems: 'echo %sh{ printf "foo\necho bar" }' runs 'echo foo', then 'echo bar'. we make this danger explicit, and we fix the 'nop %sh{...}' pattern. To reparse %sh{...} strings, they can be passed to evaluate-commands, which has been fixed to work in every cases where %sh{...} reparsing was used..
2018-05-14Rename Context::Flags::Transient to Context::Flags::DraftMaxime Coste
Draft is well establish and all draft context are transient.
2018-05-14Do not push jumps implicitely in transient contextsMaxime Coste
This should improve performance in draft contexts.
2018-04-07Make FaceRegistry scopedMaxime Coste
set-face now takes a scope argument, and faces can be overridden on a buffer or window basis. colorscheme apply on global scope, which should be good enough for now. Fixes #1411
2018-03-30Support full redraws during shell execution and handle resize thereMaxime Coste
Fixes #1973
2017-11-13Add count support to jumps (<c-o> and <c-i>). Add jumps testsDelapouite
2017-09-27Add status info when navigating through jumplist (<c-o>, <c-i>)Delapouite
2017-06-07Move NestedBool to utils.hhMaxime Coste
2017-05-23Remove unneeded forward declarationMaxime Coste
2017-03-15Small code tweaks regarding flags handlingMaxime Coste
2017-03-15Migrate WithBitOps template specialization to with_bit_ops functionMaxime Coste
This way we dont depend on knowing the base template to enable bit ops on an enum type.
2016-10-29Display a status line message when Kakoune is waiting on a shell to completeMaxime Coste
If a shell commands takes more than 1s to execute, a message will appear on the status line notifying the user, along with the time Kakoune has been waiting for.
2016-10-11Add support for repeating the last object/char find commandMaxime Coste
This is a potential solution for #794.
2016-10-10Small formatting fixupMaxime Coste
2016-09-26Make hook disabling work for all hooks, not only user hooksMaxime Coste
Fixes #823
2016-02-27Remove direct access to ui, go through clientMaxime Coste
Client can now update menu/info positions when the window move around.
2015-12-23Remove drop jump (c-d)Maxime Coste
2015-12-23Support collapsing jumps in eval and execMaxime Coste
Fixes #535
2015-12-23Use an index for jump list current rather than an iteratorMaxime Coste
2015-12-23Extract jump list handling in a JumpList structMaxime Coste
2015-11-27Support dropping last jump and use it to fix :tag double jump pushMaxime Coste
Fixes #492
2015-08-19No reason for NestedBool operator bool to be explicitMaxime Coste
2015-08-18Rename Disableable to more general NestedBoolMaxime Coste
A NestedBool can be set multiple times, and will be considered false only when unset the same number.
2015-07-13Move Context scope access helpers as inline methodsMaxime Coste
2015-04-19Make empty context construction more explicitMaxime Coste