If the 'on_paste' callback is set, LibLine will buffer the pasted data
and pass it over to the embedder to use as it pleases; in practice, this
means that the users of LibLine can now escape or otherwise handle
pasted data without the incremental codepoint-by-codepoint buildup.
After the kill_line (^U) command was used, searching backwards in the
history would still filter based on the text previous to the deletion.
Update the inline search cursor like already done in other internal
functions, so the text used for search is the current one.
I've attempted to handle the errors gracefully where it was clear how to
do so, and simple, but a lot of this was just adding
`release_value_but_fixme_should_propagate_errors()` in places.
We don't actually have a non-trivial vfork implementation, so just
call fork(). As a bonus, vfork() is deprecated in XCode 13.1 when
targeting macOS Big Sur, so this removes a blocker from updating our
macOS CI version.
Otherwise we'd end up putting the prompt *after* the previous prompt
instead of *over* it when showing suggestions that span more lines than
are available without scrolling.
Same as Vector, ByteBuffer now also signals allocation failure by
returning an ENOMEM Error instead of a bool, allowing us to use the
TRY() and MUST() patterns.
Only one place used this argument and it was to hold on to a strong ref
for the object. Since we already do that now, there's no need to keep
this argument around since this can be easily captured.
This commit contains no changes.
Previously, we were generating the display update one character at a
time, and writing them one at a time to stderr, which is not buffered,
doing so caused one syscall per character printed which is s l o w (TM)
This commit makes LibLine write the update contents into a buffer, and
flush it after all the update is generated :^)
This implements StringUtils::find_any_of() and uses it in
String::find_any_of() and StringView::find_any_of(). All uses of
find_{first,last}_of have been replaced with find_any_of(), find() or
find_last(). find_{first,last}_of have subsequently been removed.
4d5cdcc893 partially reverted the changes
from d8c5eeceab, but it reverted too much
and reintroduced the bug.
This commit finally fixes the actual bug.
The author hasn't been in his best committing state today.
We're already keeping it alive via `m_notifier`.
This makes the event loop quitting logic simpler by making less
deferred calls and removes a race condition where the notifier would be
deleted before the second deferred_invoke() would be invoked, leading
to a nullptr dereference.
Fixes#7822.
When the search editor calls on really_quit_event_loop to cancel the
search, the command loaded in m_buffer would actually execute because
really_quit_event_loop sends a new line character and then afterwards
clears the buffer.
By using end_search prior to exiting the event loop, this patch will
appropriately clear the buffer, not execute any commands, and
preserve the original loaded buffer after returning from a canceled
search.
This replaces ctype.h with CharacterType.h everywhere I could find
issues with narrowing conversions. While using it will probably make
sense almost everywhere in the future, the most critical places should
have been addressed.
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to
change though. This patch fixes a few build problems that will occur
when that change happens.
Previously, all sorts of weird stuff would happen when the editor was at
the last line of the terminal (or when the printed line would be at the
last line), this commit makes the editor scroll the terminal up before
trying to write to a row that doesn't actually exist (yet).
This fixes ^R search making a mess when initiated at the last line
(especially with multiline prompts).
This patch adds a new flag called history_dirty to Line::Editor that is
set when history is added to but written. Applications can leverage
this flag to write history only when it changes. This patch adds an
example usage of this functionality to Shell, which will now only save
the history when it is dirty.
I have no idea how this _ever_ worked, and I also have no idea why past
me didn't use FileStream to begin with.
Fixes the issue where lots of junk data would be written to the temp
file, causing the external editor to crash.
We had some inconsistencies before:
- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."
I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.
By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *