From 2d30055274ec31afbbfb6861d81da93518fdd12e Mon Sep 17 00:00:00 2001 From: quenousimporte <76260127+quenousimporte@users.noreply.github.com> Date: Mon, 30 Jan 2023 14:53:42 +0100 Subject: [PATCH] fixed: detection of last tag --- main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 65c4c18..2c3716f 100644 --- a/main.js +++ b/main.js @@ -602,7 +602,7 @@ function linkatpos() function tagatpos() { - if (md.value.lastIndexOf("tags: ", md.selectionStart) < md.value.lastIndexOf("\n", md.selectionStart)) + if (md.value.lastIndexOf("tags: ", md.selectionStart) < md.value.lastIndexOf("\n", md.selectionStart) || md.selectionStart < 6) { return null; } @@ -610,14 +610,14 @@ function tagatpos() var start = md.value.lastIndexOf(" ", md.selectionStart); if (start == -1 || md.value.substring(start, md.selectionStart).indexOf("\n") != -1) return ""; + var eol = md.value.indexOf("\n", md.selectionStart); var end = md.value.indexOf(",", md.selectionStart); - if (end == -1) + + if (end == -1 || eol < end) { - end = md.value.indexOf("\n", md.selectionStart); + end = eol; } - if (end == -1 || md.value.substring(md.selectionStart, end).indexOf("\n") != -1) return ""; - return md.value.substring(start + 1, end); }