Skip to content

Commit 782fa9f

Browse files
committed
book: Add check in todo whether entry is empty
1 parent 9a70b14 commit 782fa9f

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

book/listings/todo_app/1/window/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ impl Window {
6565
// Get content from entry and clear it
6666
let buffer = self.imp().entry.buffer();
6767
let content = buffer.text();
68+
if content.is_empty() {
69+
return;
70+
}
6871
buffer.set_text("");
6972

7073
// Add new task to model

book/listings/todo_app/2/window/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ impl Window {
127127
// Get content from entry and clear it
128128
let buffer = self.imp().entry.buffer();
129129
let content = buffer.text();
130+
if content.is_empty() {
131+
return;
132+
}
130133
buffer.set_text("");
131134

132135
// Add new task to model

book/listings/todo_app/3/window/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ impl Window {
119119
// Get content from entry and clear it
120120
let buffer = self.imp().entry.buffer();
121121
let content = buffer.text();
122+
if content.is_empty() {
123+
return;
124+
}
122125
buffer.set_text("");
123126

124127
// Add new task to model

book/listings/todo_app/4/window/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ impl Window {
116116
// Get content from entry and clear it
117117
let buffer = self.imp().entry.buffer();
118118
let content = buffer.text();
119+
if content.is_empty() {
120+
return;
121+
}
119122
buffer.set_text("");
120123

121124
// Add new task to model

0 commit comments

Comments
 (0)