aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editor.mjs27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/editor.mjs b/src/editor.mjs
index 7cb0525..2df4279 100644
--- a/src/editor.mjs
+++ b/src/editor.mjs
@@ -173,7 +173,7 @@ const insideCodeblockForMap = (anchor) => {
173 return result 173 return result
174} 174}
175// }}} 175// }}}
176// FUNCTION: Get renderer by cursor position in code block {{{ 176// FUNCTION: Get Renderer by cursor position in code block {{{
177const getLineWithRenderer = (anchor) => { 177const getLineWithRenderer = (anchor) => {
178 const currentLine = anchor.line 178 const currentLine = anchor.line
179 const match = (line) => cm.getLine(line).match(/^use: /) 179 const match = (line) => cm.getLine(line).match(/^use: /)
@@ -182,25 +182,26 @@ const getLineWithRenderer = (anchor) => {
182 182
183 183
184 // Look backward/forward for pattern of used renderer: /use: .+/ 184 // Look backward/forward for pattern of used renderer: /use: .+/
185 let ps = currentLine - 1 185 let pl = currentLine - 1
186 while (ps > 0 && insideCodeblockForMap(anchor)) { 186 while (pl > 0 && insideCodeblockForMap(anchor)) {
187 if (match(ps)) { 187 const text = cm.getLine(pl)
188 return ps 188 if (match(pl)) {
189 } else if (cm.getLine(ps).match(/^---/)) { 189 return pl
190 // If yaml doc separator is found 190 } else if (text.match(/^---|^````*/)) {
191 break 191 break
192 } 192 }
193 ps = ps - 1 193 pl = pl - 1
194 } 194 }
195 195
196 let ns = currentLine + 1 196 let nl = currentLine + 1
197 while (insideCodeblockForMap(anchor)) { 197 while (insideCodeblockForMap(anchor)) {
198 if (match(ns)) { 198 const text = cm.getLine(nl)
199 return ns 199 if (match(nl)) {
200 } else if (cm.getLine(ns).match(/^---/)) { 200 return nl
201 } else if (text.match(/^---|^````*/)) {
201 return null 202 return null
202 } 203 }
203 ns = ns + 1 204 nl = nl + 1
204 } 205 }
205 206
206 return null 207 return null