From 1ae8087ae3f17c218f0161e8f2b285a3647f33fc Mon Sep 17 00:00:00 2001 From: Junyi Du Date: Mon, 29 Nov 2021 16:59:28 +0800 Subject: [PATCH] fix: DWIM isn't activated at one-line block --- src/main/frontend/util/cursor.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/util/cursor.cljs b/src/main/frontend/util/cursor.cljs index 7e40f8af9..d4e7ad661 100644 --- a/src/main/frontend/util/cursor.cljs +++ b/src/main/frontend/util/cursor.cljs @@ -91,7 +91,9 @@ [input] (let [[content pos] (get-input-content&pos input)] (if (zero? pos) 0 - (inc (string/last-index-of content \newline (dec pos)))))) + (let [last-newline-pos (string/last-index-of content \newline (dec pos))] + (if (= nil last-newline-pos) 0 ;; no newline found (first line) + (inc last-newline-pos)))))) (defn line-end-pos [input]