aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2009-02-08 21:46:56 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2009-02-08 21:46:56 -0500
commit638b667398201d00989c055d90637ffce20bd1d3 (patch)
treeac5db3b8b051945a73e823d3bd777dd3418cd226
parent19a09c7ea4a25b55fe5b0dcff33a4d40fc320b3b (diff)
downloadtextadept-638b667398201d00989c055d90637ffce20bd1d3.tar.gz
textadept-638b667398201d00989c055d90637ffce20bd1d3.zip
Do not do any find/replace when there is no find text.
-rw-r--r--core/ext/find.lua2
-rw-r--r--src/textadept.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/core/ext/find.lua b/core/ext/find.lua
index 5aea4a35..cc7763d6 100644
--- a/core/ext/find.lua
+++ b/core/ext/find.lua
@@ -31,6 +31,7 @@ local escapes = {
-- internally, and should not be set otherwise.
-- @return position of the found text or -1
function find.find(text, next, flags, nowrap, wrapped)
+ if #text == 0 then return end
local buffer = buffer
local locale = textadept.locale
local first_visible_line = buffer.first_visible_line -- for 'no results found'
@@ -209,6 +210,7 @@ end
-- @param flags The number mask identical to the one in 'find'.
-- @see find.find
function find.replace_all(ftext, rtext, flags)
+ if #ftext == 0 then return end
local buffer = buffer
if find.in_files then find.in_files = false end
buffer:begin_undo_action()
diff --git a/src/textadept.c b/src/textadept.c
index d2836397..ee2f4da6 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -973,6 +973,7 @@ static void find_add_to_history(const char *text, GtkListStore *store) {
static void button_clicked(GtkWidget *button, gpointer) {
const char *find_text = gtk_entry_get_text(GTK_ENTRY(find_entry));
const char *repl_text = gtk_entry_get_text(GTK_ENTRY(replace_entry));
+ if (strlen(find_text) == 0) return;
if (button == fnext_button || button == fprev_button) {
find_add_to_history(find_text, find_store);
l_find(find_text, button == fnext_button);