@@ -77,6 +77,11 @@ impl Editor {
77
77
}
78
78
}
79
79
80
+ // If no target is given, do nothing
81
+ if target. is_empty ( ) {
82
+ return Ok ( ( ) ) ;
83
+ }
84
+
80
85
// Main body of the search feature
81
86
let mut done = false ;
82
87
let Size { w, h } = size ( ) ?;
@@ -127,6 +132,10 @@ impl Editor {
127
132
128
133
/// Move to the next match
129
134
pub fn next_match ( & mut self , target : & str ) -> Option < String > {
135
+ if target. is_empty ( ) {
136
+ return None ;
137
+ }
138
+
130
139
if let Some ( doc) = self . try_doc_mut ( ) {
131
140
let mtch = doc. next_match ( target, 1 ) ?;
132
141
// Select match
@@ -145,6 +154,10 @@ impl Editor {
145
154
146
155
/// Move to the previous match
147
156
pub fn prev_match ( & mut self , target : & str ) -> Option < String > {
157
+ if target. is_empty ( ) {
158
+ return None ;
159
+ }
160
+
148
161
if let Some ( doc) = self . try_doc_mut ( ) {
149
162
let mtch = doc. prev_match ( target) ?;
150
163
doc. move_to ( & mtch. loc ) ;
@@ -172,6 +185,10 @@ impl Editor {
172
185
let editor_bg = Bg ( config ! ( self . config, colors) . editor_bg . to_color ( ) ?) ;
173
186
// Request replace information
174
187
let target = self . prompt ( "Replace" ) ?;
188
+ // If no target is given, do nothing
189
+ if target. is_empty ( ) {
190
+ return Ok ( ( ) ) ;
191
+ }
175
192
let into = self . prompt ( "With" ) ?;
176
193
let mut done = false ;
177
194
let Size { w, h } = size ( ) ?;
0 commit comments