From ca32d749ed16b3f72f968b740da007aad99488fa Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 21 May 2021 13:57:36 +0100 Subject: [PATCH] fix highlight url hash ordering --- src/components/EditorTextArea.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/EditorTextArea.js b/src/components/EditorTextArea.js index 974eddc..bc2fa07 100644 --- a/src/components/EditorTextArea.js +++ b/src/components/EditorTextArea.js @@ -112,8 +112,9 @@ function useSelectedLine() { useEffect(() => { if (selected[0] !== -1) { if (selected[1] !== -1) { - const [s, e] = selected.sort(); - window.location.hash = `#L${s}-${e}`; + const start = Math.min(...selected); + const end = Math.max(...selected); + window.location.hash = `#L${start}-${end}`; } else { window.location.hash = `#L${selected[0]}`; }