diff --git a/hermes_cli/main.py b/hermes_cli/main.py index cbfdec5a37..1a01e67c46 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -868,7 +868,7 @@ def _tui_need_npm_install(root: Path) -> bool: try: wanted = json.loads(lock.read_text(encoding="utf-8")).get("packages") or {} installed = json.loads(marker.read_text(encoding="utf-8")).get("packages") or {} - except (OSError, json.JSONDecodeError): + except (OSError, UnicodeDecodeError, json.JSONDecodeError): return lock.stat().st_mtime > marker.stat().st_mtime def comparable(pkg: dict) -> dict: diff --git a/ui-tui/src/components/textInput.tsx b/ui-tui/src/components/textInput.tsx index 9ef0284abb..e5d21a4893 100644 --- a/ui-tui/src/components/textInput.tsx +++ b/ui-tui/src/components/textInput.tsx @@ -638,14 +638,14 @@ export function TextInput({ const moveCursor = (next: number, extend = false) => { const c = snapPos(vRef.current, next) + const anchor = selRef.current?.start ?? curRef.current - if (extend) { - const anchor = selRef.current?.start ?? curRef.current + if (!extend || anchor === c) { + clearSel() + } else { const nextSel = { end: c, start: anchor } selRef.current = nextSel setSel(nextSel) - } else { - clearSel() } setCur(c)