Skip to content
Snippets Groups Projects
Commit 9e6d113c authored by rswindell's avatar rswindell
Browse files

Don't crash when the 'E'dit and 'R'emove commands are used with an empty

list.
parent 68fc7fd0
No related branches found
No related tags found
No related merge requests found
...@@ -1138,7 +1138,7 @@ function browse(list) ...@@ -1138,7 +1138,7 @@ function browse(list)
var prompt = ""; var prompt = "";
if(!options.add_ars || user.compare_ars(options.add_ars)) if(!options.add_ars || user.compare_ars(options.add_ars))
prompt += "~Add, "; prompt += "~Add, ";
if(can_edit(list[current])) if(list.length && can_edit(list[current]))
prompt += "~Edit, ~Remove, "; prompt += "~Edit, ~Remove, ";
console.mnemonics(prompt + "~Download, ~Sort, ~Format, ~Quit, ~Help ~?"); console.mnemonics(prompt + "~Download, ~Sort, ~Format, ~Quit, ~Help ~?");
var key = console.getkey(K_UPPER); var key = console.getkey(K_UPPER);
...@@ -1150,6 +1150,10 @@ function browse(list) ...@@ -1150,6 +1150,10 @@ function browse(list)
list = orglist.slice(); list = orglist.slice();
continue; continue;
case 'E': case 'E':
if(!list[current] || !can_edit(list[current])) {
console_beep();
continue;
}
console.clear(); console.clear();
/* Edit a clone, not the original (allowing the user to abort the edit) */ /* Edit a clone, not the original (allowing the user to abort the edit) */
var bbs = edit(objcopy(list[current])); var bbs = edit(objcopy(list[current]));
...@@ -1164,7 +1168,7 @@ function browse(list) ...@@ -1164,7 +1168,7 @@ function browse(list)
continue; continue;
case KEY_DEL: case KEY_DEL:
case 'R': case 'R':
if(!can_edit(list[current])) { if(!list[current] || !can_edit(list[current])) {
console_beep(); console_beep();
continue; continue;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment