about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--edit.lua10
-rw-r--r--search.lua4
2 files changed, 5 insertions, 9 deletions
diff --git a/edit.lua b/edit.lua
index 91ea8e0..9e80cc3 100644
--- a/edit.lua
+++ b/edit.lua
@@ -426,14 +426,10 @@ function edit.keychord_press(State, chord, key)
       State.screen_top = deepcopy(State.search_backup.screen_top)
       Text.search_next(State)
     elseif chord == 'down' then
-      if #State.search_term > 0 then
-        edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
-        Text.search_next(State)
-      end
+      edit.put_cursor_on_next_text_loc_wrapping_around_if_necessary(State)
+      Text.search_next(State)
     elseif chord == 'up' then
-      if #State.search_term > 0 then
-        Text.search_previous(State)
-      end
+      Text.search_previous(State)
     end
     return
   elseif chord == 'C-f' then
diff --git a/search.lua b/search.lua
index 2b4ea99..4aa1f02 100644
--- a/search.lua
+++ b/search.lua
@@ -17,7 +17,7 @@ function Text.draw_search_bar(State)
 end
 
 function Text.search_next(State)
-  assert(#State.search_term > 0)
+  if #State.search_term == 0 then return end
   -- search current line from cursor
   local curr_pos = State.cursor1.pos
   local curr_line = State.lines[State.cursor1.line].data
@@ -72,7 +72,7 @@ function Text.search_next(State)
 end
 
 function Text.search_previous(State)
-  assert(#State.search_term > 0)
+  if #State.search_term == 0 then return end
   -- search current line before cursor
   local curr_pos = State.cursor1.pos
   local curr_line = State.lines[State.cursor1.line].data
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
parse/0: instruction: copy
parse/0:   ingredient: {name: "5", value: 0, type: 0, properties: ["5": "literal"]}
parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0: instruction: copy
parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: ["1": "literal"]}
parse/0:   product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0: label: {
parse/0: instruction: equal
parse/0:   ingredient: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: ["1": "literal"]}
parse/0:   product: {name: "3", value: 0, type: 3, properties: ["3": "boolean"]}
parse/0: instruction: break-if
parse/0:   ingredient: {name: "3", value: 0, type: 3, properties: ["3": "boolean"]}
parse/0: instruction: multiply
parse/0:   ingredient: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0:   ingredient: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0:   product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0: instruction: subtract
parse/0:   ingredient: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: ["1": "literal"]}
parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
parse/0: instruction: loop
parse/0: label: }
parse/0: instruction: copy
parse/0:   ingredient: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
parse/0:   product: {name: "4", value: 0, type: 1, properties: ["4": "integer"]}
brace/0: 1000: push (open, 2)
brace/0: push (close, 8)
after-brace/0: recipe test-factorial
after-brace/0: copy ...
after-brace/0: copy ...
after-brace/0: equal ...
after-brace/0: jump-if 3, 3:offset
after-brace/0: multiply ...
after-brace/0: subtract ...
after-brace/0: jump -5:offset
after-brace/0: 7: {name: "", value: -5, type: , properties: ["": ]}
after-brace/0: 7: {name: "", value: -5, type: , properties: ["": ]}
after-brace/0: copy ...
new/0: routine allocated memory from 1000 to 101000
schedule/0: test-factorial
run/0: instruction test-factorial/0
run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- copy/1 {name: "5", value: 5, type: 0, properties: ["5": "literal"]}
run/0: ingredient 0 is 5
mem/0: storing 5 in location 1
run/0: instruction test-factorial/1
run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- copy/1 {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: storing 1 in location 2
run/0: instruction test-factorial/3
run/0: {name: "3", value: 3, type: 3, properties: ["3": "boolean"]} <- equal/13 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 5
run/0: ingredient 1 is 1
run/0: product 0 is 0
mem/0: storing 0 in location 3
run/0: instruction test-factorial/4
run/0: break-if/11 {name: "3", value: 3, type: 3, properties: ["3": "boolean"]}, {name: "", value: 3, type: , properties: ["": ]}
mem/0: location 3 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction test-factorial/5
run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- multiply/4 {name: "2", value: 2, type: 1, properties: ["2": "integer"]}, {name: "1", value: 1, type: 1, properties: ["1": "integer"]}
run/0: ingredient 0 is 2
mem/0: location 2 is 1
run/0: ingredient 1 is 1
mem/0: location 1 is 5
run/0: ingredient 1 is 5
run/0: product 0 is 5
mem/0: storing 5 in location 2
run/0: instruction test-factorial/6
run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- subtract/3 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 5
run/0: ingredient 1 is 1
run/0: product 0 is 4
mem/0: storing 4 in location 1
run/0: instruction test-factorial/7
run/0: loop/10 {name: "", value: -5, type: , properties: ["": ]}
run/0: ingredient 0 is -5
run/0: jumping to instruction 3
run/0: instruction test-factorial/3
run/0: {name: "3", value: 3, type: 3, properties: ["3": "boolean"]} <- equal/13 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 4
run/0: ingredient 1 is 1
run/0: product 0 is 0
mem/0: storing 0 in location 3
run/0: instruction test-factorial/4
run/0: break-if/11 {name: "3", value: 3, type: 3, properties: ["3": "boolean"]}, {name: "", value: 3, type: , properties: ["": ]}
mem/0: location 3 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction test-factorial/5
run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- multiply/4 {name: "2", value: 2, type: 1, properties: ["2": "integer"]}, {name: "1", value: 1, type: 1, properties: ["1": "integer"]}
run/0: ingredient 0 is 2
mem/0: location 2 is 5
run/0: ingredient 1 is 1
mem/0: location 1 is 4
run/0: ingredient 1 is 4
run/0: product 0 is 20
mem/0: storing 20 in location 2
run/0: instruction test-factorial/6
run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- subtract/3 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 4
run/0: ingredient 1 is 1
run/0: product 0 is 3
mem/0: storing 3 in location 1
run/0: instruction test-factorial/7
run/0: loop/10 {name: "", value: -5, type: , properties: ["": ]}
run/0: ingredient 0 is -5
run/0: jumping to instruction 3
run/0: instruction test-factorial/3
run/0: {name: "3", value: 3, type: 3, properties: ["3": "boolean"]} <- equal/13 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 3
run/0: ingredient 1 is 1
run/0: product 0 is 0
mem/0: storing 0 in location 3
run/0: instruction test-factorial/4
run/0: break-if/11 {name: "3", value: 3, type: 3, properties: ["3": "boolean"]}, {name: "", value: 3, type: , properties: ["": ]}
mem/0: location 3 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction test-factorial/5
run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- multiply/4 {name: "2", value: 2, type: 1, properties: ["2": "integer"]}, {name: "1", value: 1, type: 1, properties: ["1": "integer"]}
run/0: ingredient 0 is 2
mem/0: location 2 is 20
run/0: ingredient 1 is 1
mem/0: location 1 is 3
run/0: ingredient 1 is 3
run/0: product 0 is 60
mem/0: storing 60 in location 2
run/0: instruction test-factorial/6
run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- subtract/3 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 3
run/0: ingredient 1 is 1
run/0: product 0 is 2
mem/0: storing 2 in location 1
run/0: instruction test-factorial/7
run/0: loop/10 {name: "", value: -5, type: , properties: ["": ]}
run/0: ingredient 0 is -5
run/0: jumping to instruction 3
run/0: instruction test-factorial/3
run/0: {name: "3", value: 3, type: 3, properties: ["3": "boolean"]} <- equal/13 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 2
run/0: ingredient 1 is 1
run/0: product 0 is 0
mem/0: storing 0 in location 3
run/0: instruction test-factorial/4
run/0: break-if/11 {name: "3", value: 3, type: 3, properties: ["3": "boolean"]}, {name: "", value: 3, type: , properties: ["": ]}
mem/0: location 3 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction test-factorial/5
run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- multiply/4 {name: "2", value: 2, type: 1, properties: ["2": "integer"]}, {name: "1", value: 1, type: 1, properties: ["1": "integer"]}
run/0: ingredient 0 is 2
mem/0: location 2 is 60
run/0: ingredient 1 is 1
mem/0: location 1 is 2
run/0: ingredient 1 is 2
run/0: product 0 is 120
mem/0: storing 120 in location 2
run/0: instruction test-factorial/6
run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- subtract/3 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 2
run/0: ingredient 1 is 1
run/0: product 0 is 1
mem/0: storing 1 in location 1
run/0: instruction test-factorial/7
run/0: loop/10 {name: "", value: -5, type: , properties: ["": ]}
run/0: ingredient 0 is -5
run/0: jumping to instruction 3
run/0: instruction test-factorial/3
run/0: {name: "3", value: 3, type: 3, properties: ["3": "boolean"]} <- equal/13 {name: "1", value: 1, type: 1, properties: ["1": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is 1
mem/0: location 1 is 1
run/0: ingredient 1 is 1
run/0: product 0 is 1
mem/0: storing 1 in location 3
run/0: instruction test-factorial/4
run/0: break-if/11 {name: "3", value: 3, type: 3, properties: ["3": "boolean"]}, {name: "", value: 3, type: , properties: ["": ]}
mem/0: location 3 is 1
run/0: ingredient 0 is 1
run/0: ingredient 1 is 
run/0: jumping to instruction 8
run/0: instruction test-factorial/9
run/0: {name: "4", value: 4, type: 1, properties: ["4": "integer"]} <- copy/1 {name: "2", value: 2, type: 1, properties: ["2": "integer"]}
run/0: ingredient 0 is 2
mem/0: location 2 is 120
mem/0: storing 120 in location 4