summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-01-31 15:07:33 +0100
committerAlbert Cervin <albert@acervin.com>2024-01-31 15:07:33 +0100
commitcea4819feb55559408c3b58872f6e3e6a32ae0e5 (patch)
tree553c37508c672fa20c2c18dad59abc49fdc20b5e /src/main
parent9382250e21488feec982ff7dfffb5df05b39a290 (diff)
downloaddged-cea4819feb55559408c3b58872f6e3e6a32ae0e5.tar.gz
dged-cea4819feb55559408c3b58872f6e3e6a32ae0e5.tar.xz
dged-cea4819feb55559408c3b58872f6e3e6a32ae0e5.zip
Fix replace crash
Was using the minibuffer instead of the actual buffer.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/search-replace.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/main/search-replace.c b/src/main/search-replace.c
index 6467ee1..6fe7c66 100644
--- a/src/main/search-replace.c
+++ b/src/main/search-replace.c
@@ -18,6 +18,7 @@ static struct replace {
uint32_t nmatches;
uint32_t current_match;
buffer_keymap_id keymap_id;
+ struct window *window;
} g_current_replace = {0};
void abort_replace() {
@@ -27,6 +28,7 @@ void abort_replace() {
g_current_replace.matches = NULL;
g_current_replace.replace = NULL;
g_current_replace.nmatches = 0;
+ g_current_replace.window = NULL;
minibuffer_abort_prompt();
}
@@ -78,7 +80,7 @@ static void highlight_matches(struct buffer *buffer, struct region *matches,
static int32_t replace_next(struct command_ctx ctx, int argc,
const char *argv[]) {
struct replace *state = &g_current_replace;
- struct buffer_view *buffer_view = window_buffer_view(windows_get_active());
+ struct buffer_view *buffer_view = window_buffer_view(state->window);
struct region *m = &state->matches[state->current_match];
buffer_view_set_mark_at(buffer_view, (struct location){.line = m->begin.line,
@@ -106,7 +108,7 @@ static int32_t replace_next(struct command_ctx ctx, int argc,
static int32_t skip_next(struct command_ctx ctx, int argc, const char *argv[]) {
struct replace *state = &g_current_replace;
- struct buffer_view *buffer_view = window_buffer_view(windows_get_active());
+ struct buffer_view *buffer_view = window_buffer_view(state->window);
struct region *m = &state->matches[state->current_match];
buffer_view_goto(buffer_view, (struct location){.line = m->end.line,
.col = m->end.col + 1});
@@ -182,6 +184,7 @@ static int32_t replace(struct command_ctx ctx, int argc, const char *argv[]) {
.matches = matches,
.nmatches = nmatches,
.current_match = 0,
+ .window = ctx.active_window,
};
struct region *m = &g_current_replace.matches[0];