From 77e63d3113a785c5cfc2cf027a781a7ec080f362 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 28 Aug 2023 11:21:39 +0200 Subject: [PATCH] fixed: cursor pos in % when content is empty --- main.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 92fec49..fe93751 100644 --- a/main.js +++ b/main.js @@ -510,6 +510,11 @@ function formatsize(size) return size.toFixed(2) + " " + unit; } +function pospercent() +{ + return md.value.length > 0 ?(100 * md.selectionStart / md.value.length).toFixed(2) : 100; +} + function showinfo() { var tags = gettags(currentnote); @@ -518,7 +523,7 @@ function showinfo() "vault: " + currentvault, "saved: " + saved, "title: " + currentnote.title, - "cursor position: " + md.selectionStart + " (" + (100 * md.selectionStart / md.value.length).toFixed(2) + "%)", + "cursor position: " + md.selectionStart + " (" + pospercent() + "%)", (tags ? "tags: " + tags : ""), "spell check: " + (md.spellcheck ? "en" : "dis") + "abled", "notes count: " + localdata.length,