File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -317,22 +317,28 @@ export default class CodeEditor extends React.Component {
317
317
const snippetLines = snippets [ i ] . content . split ( '\n' )
318
318
let cursorLineNumber = 0
319
319
let cursorLinePosition = 0
320
+
321
+ let cursorIndex
320
322
for ( let j = 0 ; j < snippetLines . length ; j ++ ) {
321
- const cursorIndex = snippetLines [ j ] . indexOf ( templateCursorString )
323
+ cursorIndex = snippetLines [ j ] . indexOf ( templateCursorString )
324
+
322
325
if ( cursorIndex !== - 1 ) {
323
326
cursorLineNumber = j
324
327
cursorLinePosition = cursorIndex
325
- cm . replaceRange (
326
- snippets [ i ] . content . replace ( templateCursorString , '' ) ,
327
- wordBeforeCursor . range . from ,
328
- wordBeforeCursor . range . to
329
- )
330
- cm . setCursor ( {
331
- line : cursor . line + cursorLineNumber ,
332
- ch : cursorLinePosition
333
- } )
328
+
329
+ break
334
330
}
335
331
}
332
+
333
+ cm . replaceRange (
334
+ snippets [ i ] . content . replace ( templateCursorString , '' ) ,
335
+ wordBeforeCursor . range . from ,
336
+ wordBeforeCursor . range . to
337
+ )
338
+ cm . setCursor ( {
339
+ line : cursor . line + cursorLineNumber ,
340
+ ch : cursorLinePosition + cursor . ch - wordBeforeCursor . text . length
341
+ } )
336
342
} else {
337
343
cm . replaceRange (
338
344
snippets [ i ] . content ,
You can’t perform that action at this time.
0 commit comments