fixed: cursor pos in % when content is empty

This commit is contained in:
quenousimporte 2023-08-28 11:21:39 +02:00
parent 6122e20e3d
commit 77e63d3113
1 changed files with 6 additions and 1 deletions

View File

@ -510,6 +510,11 @@ function formatsize(size)
return size.toFixed(2) + " " + unit; return size.toFixed(2) + " " + unit;
} }
function pospercent()
{
return md.value.length > 0 ?(100 * md.selectionStart / md.value.length).toFixed(2) : 100;
}
function showinfo() function showinfo()
{ {
var tags = gettags(currentnote); var tags = gettags(currentnote);
@ -518,7 +523,7 @@ function showinfo()
"vault: " + currentvault, "vault: " + currentvault,
"saved: " + saved, "saved: " + saved,
"title: " + currentnote.title, "title: " + currentnote.title,
"cursor position: " + md.selectionStart + " (" + (100 * md.selectionStart / md.value.length).toFixed(2) + "%)", "cursor position: " + md.selectionStart + " (" + pospercent() + "%)",
(tags ? "tags: " + tags : ""), (tags ? "tags: " + tags : ""),
"spell check: " + (md.spellcheck ? "en" : "dis") + "abled", "spell check: " + (md.spellcheck ? "en" : "dis") + "abled",
"notes count: " + localdata.length, "notes count: " + localdata.length,