aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vis-core.h1
-rw-r--r--vis-text-objects.c14
-rw-r--r--vis.c3
-rw-r--r--vis.h2
4 files changed, 13 insertions, 7 deletions
diff --git a/vis-core.h b/vis-core.h
index fc42a37..4a5d3fc 100644
--- a/vis-core.h
+++ b/vis-core.h
@@ -146,7 +146,6 @@ struct Vis {
Macro *recording, *last_recording; /* currently (if non NULL) and least recently recorded macro */
Macro *macro_operator; /* special macro used to repeat certain operators */
Mode *mode_before_prompt; /* user mode which was active before entering prompt */
- Regex *search_pattern; /* last used search pattern */
char search_char[8]; /* last used character to search for via 'f', 'F', 't', 'T' */
int last_totill; /* last to/till movement used for ';' and ',' */
int tabwidth; /* how many spaces should be used to display a tab */
diff --git a/vis-text-objects.c b/vis-text-objects.c
index ebb7384..962c22c 100644
--- a/vis-text-objects.c
+++ b/vis-text-objects.c
@@ -31,11 +31,21 @@ bool vis_textobject(Vis *vis, enum VisTextObject id) {
}
static Filerange search_forward(Vis *vis, Text *txt, size_t pos) {
- return text_object_search_forward(txt, pos, vis->search_pattern);
+ Filerange range = text_range_empty();
+ Regex *regex = vis_regex(vis, NULL);
+ if (regex)
+ range = text_object_search_forward(txt, pos, regex);
+ text_regex_free(regex);
+ return range;
}
static Filerange search_backward(Vis *vis, Text *txt, size_t pos) {
- return text_object_search_backward(txt, pos, vis->search_pattern);
+ Filerange range = text_range_empty();
+ Regex *regex = vis_regex(vis, NULL);
+ if (regex)
+ range = text_object_search_backward(txt, pos, regex);
+ text_regex_free(regex);
+ return range;
}
const TextObject vis_textobjects[] = {
diff --git a/vis.c b/vis.c
index 7c04347..7794e89 100644
--- a/vis.c
+++ b/vis.c
@@ -335,8 +335,6 @@ Vis *vis_new(Ui *ui, VisEvent *event) {
vis->registers[VIS_REG_BLACKHOLE].type = REGISTER_BLACKHOLE;
vis->registers[VIS_REG_CLIPBOARD].type = REGISTER_CLIPBOARD;
action_reset(&vis->action);
- if (!(vis->search_pattern = text_regex_new()))
- goto err;
if (!(vis->command_file = file_new_internal(vis, NULL)))
goto err;
if (!(vis->search_file = file_new_internal(vis, NULL)))
@@ -364,7 +362,6 @@ void vis_free(Vis *vis) {
vis_window_close(vis->windows);
file_free(vis, vis->command_file);
file_free(vis, vis->search_file);
- text_regex_free(vis->search_pattern);
for (int i = 0; i < LENGTH(vis->registers); i++)
register_release(&vis->registers[i]);
vis->ui->free(vis->ui);
diff --git a/vis.h b/vis.h
index 0bafe68..c90c80a 100644
--- a/vis.h
+++ b/vis.h
@@ -352,7 +352,7 @@ enum VisRegister {
VIS_REG_PROMPT, /* internal register which shadows DEFAULT in PROMPT mode */
VIS_MACRO_OPERATOR, /* records entered keys after an operator */
VIS_MACRO_REPEAT, /* copy of the above macro once the recording is finished */
- VIS_REG_SEARCH,
+ VIS_REG_SEARCH, /* last used search pattern "/ */
VIS_REG_INVALID, /* has to be the last 'real' register */
VIS_REG_A, VIS_REG_B, VIS_REG_C, VIS_REG_D, VIS_REG_E,
VIS_REG_F, VIS_REG_G, VIS_REG_H, VIS_REG_I, VIS_REG_J,