aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/ui-commander.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ext/ui-commander.js')
-rw-r--r--modules/ext/ui-commander.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/ext/ui-commander.js b/modules/ext/ui-commander.js
index 4ffdc8b..03af5be 100644
--- a/modules/ext/ui-commander.js
+++ b/modules/ext/ui-commander.js
@@ -82,7 +82,16 @@ body[data-ui-mode="commander"] #ui-root { display: grid; grid-template-columns:
const name = String(entry.name);
const isDir = entry.type === 'dir' || entry._virtual;
const it = api.el('div', { class: 'item', text: (isDir ? '📁 ' : '📄 ') + name });
- it.addEventListener('click', () => api.exec((isDir ? 'ls ' : 'cat ') + name));
+ // Quote the path: a VFS name with a space split into two arguments, and a leading `-`
+ // became an option flag (found by review).
+ const quoted = "'" + String(name).replace(/'/g, "'\\''") + "'";
+ const run = () => api.exec((isDir ? 'ls ' : 'cat ') + quoted);
+ it.addEventListener('click', run);
+ it.tabIndex = 0;
+ it.setAttribute('role', 'button');
+ it.addEventListener('keydown', (ev) => {
+ if (ev.key === 'Enter' || ev.key === ' ') { ev.preventDefault(); run(); }
+ });
left.appendChild(it);
});
} catch (e) { left.appendChild(api.el('div', { class: 'item', text: '(' + e.message + ')' })); }