mirror of
https://github.com/mawww/kakoune.git
synced 2024-08-17 00:30:26 +03:00
Compare commits
6 Commits
8d55602800
...
a4fb92eb5c
Author | SHA1 | Date | |
---|---|---|---|
|
a4fb92eb5c | ||
|
0a10612786 | ||
|
07000adb9b | ||
|
374a7a8c99 | ||
|
6674fe7587 | ||
|
0bb355557e |
@ -147,6 +147,11 @@ name. Hooks with no description will always use an empty string.
|
||||
*SessionRenamed* `<old name>:<new name>`::
|
||||
executed when a session is renamed using the `rename-session` command
|
||||
|
||||
*EnterDirectory* `path`::
|
||||
executed on startup and when the current working directory is changed
|
||||
using the `change-directory` command. The hook param is an absolute path
|
||||
to the new working directory.
|
||||
|
||||
*RuntimeError* `error message`::
|
||||
an error was encountered while executing a user command
|
||||
|
||||
|
@ -8,7 +8,7 @@ hook global BufCreate .*[.](ex|exs) %{
|
||||
set-option buffer filetype elixir
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]html[.]l?eex %{
|
||||
hook global BufCreate .*[.]html[.][lh]?eex %{
|
||||
set-option buffer filetype eex
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ add-highlighter shared/elixir/single_string region "'" "(?<!\\)(?:\\\\)*'" fill
|
||||
add-highlighter shared/elixir/comment region '#' '$' fill comment
|
||||
|
||||
add-highlighter shared/elixir/leex region -match-capture '~L("""|")' '(?<!\\)(?:\\\\)*("""|")' ref eex
|
||||
add-highlighter shared/elixir/heex region -match-capture '~H("""|")' '(?<!\\)(?:\\\\)*("""|")' ref eex
|
||||
|
||||
add-highlighter shared/elixir/double_string/base default-region fill string
|
||||
add-highlighter shared/elixir/double_string/interpolation region -recurse \{ \Q#{ \} fill builtin
|
||||
|
@ -2600,13 +2600,15 @@ const CommandDesc change_directory_cmd = {
|
||||
cursor_pos, FilenameFlags::OnlyDirectories),
|
||||
Completions::Flags::Menu };
|
||||
}),
|
||||
[](const ParametersParser& parser, Context&, const ShellContext&)
|
||||
[](const ParametersParser& parser, Context& ctx, const ShellContext&)
|
||||
{
|
||||
StringView target = parser.positional_count() == 1 ? StringView{parser[0]} : "~";
|
||||
if (chdir(parse_filename(target).c_str()) != 0)
|
||||
auto path = real_path(parse_filename(target));
|
||||
if (chdir(path.c_str()) != 0)
|
||||
throw runtime_error(format("unable to change to directory: '{}'", target));
|
||||
for (auto& buffer : BufferManager::instance())
|
||||
buffer->update_display_name();
|
||||
ctx.hooks().run_hook(Hook::EnterDirectory, path, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,6 +50,7 @@ enum class Hook
|
||||
NextKeyIdle,
|
||||
NormalKey,
|
||||
ModeChange,
|
||||
EnterDirectory,
|
||||
RawKey,
|
||||
RegisterModified,
|
||||
WinClose,
|
||||
@ -97,6 +98,7 @@ constexpr auto enum_desc(Meta::Type<Hook>)
|
||||
{Hook::NextKeyIdle, "NextKeyIdle"},
|
||||
{Hook::NormalKey, "NormalKey"},
|
||||
{Hook::ModeChange, "ModeChange"},
|
||||
{Hook::EnterDirectory, "EnterDirectory"},
|
||||
{Hook::RawKey, "RawKey"},
|
||||
{Hook::RegisterModified, "RegisterModified"},
|
||||
{Hook::WinClose, "WinClose"},
|
||||
|
@ -842,6 +842,7 @@ int run_server(StringView session, StringView server_init,
|
||||
|
||||
{
|
||||
Context empty_context{Context::EmptyContextFlag{}};
|
||||
global_scope.hooks().run_hook(Hook::EnterDirectory, real_path("."), empty_context);
|
||||
global_scope.hooks().run_hook(Hook::KakBegin, session, empty_context);
|
||||
}
|
||||
|
||||
|
@ -589,13 +589,13 @@ void pipe(Context& context, NormalParams params)
|
||||
return;
|
||||
|
||||
Buffer& buffer = context.buffer();
|
||||
SelectionList selections = context.selections();
|
||||
if (replace)
|
||||
{
|
||||
buffer.throw_if_read_only();
|
||||
ScopedEdition edition(context);
|
||||
ForwardChangesTracker changes_tracker;
|
||||
size_t timestamp = buffer.timestamp();
|
||||
Vector<Selection> new_sels;
|
||||
SelectionList selections = context.selections();
|
||||
for (auto& sel : selections)
|
||||
{
|
||||
const auto beg = changes_tracker.get_new_coord_tolerant(sel.min());
|
||||
@ -614,20 +614,27 @@ void pipe(Context& context, NormalParams params)
|
||||
|
||||
auto new_end = apply_diff(buffer, beg, in, out);
|
||||
if (new_end != beg)
|
||||
new_sels.push_back(keep_direction({beg, buffer.char_prev(new_end), std::move(sel.captures())}, sel));
|
||||
{
|
||||
auto& min = sel.min();
|
||||
auto& max = sel.max();
|
||||
min = beg;
|
||||
max = buffer.char_prev(new_end);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (new_end != BufferCoord{})
|
||||
new_end = buffer.char_prev(new_end);
|
||||
new_sels.push_back({new_end, new_end, std::move(sel.captures())});
|
||||
sel.set(new_end);
|
||||
}
|
||||
|
||||
changes_tracker.update(buffer, timestamp);
|
||||
}
|
||||
context.selections_write_only().set(std::move(new_sels), selections.main_index());
|
||||
selections.force_timestamp(timestamp);
|
||||
context.selections_write_only() = std::move(selections);
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectionList& selections = context.selections();
|
||||
const auto old_main = selections.main_index();
|
||||
for (int i = 0; i < selections.size(); ++i)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user