(cm, repeat, forward, symb)
| 3502 | } |
| 3503 | }; |
| 3504 | function findSymbol(cm, repeat, forward, symb) { |
| 3505 | var cur = copyCursor(cm.getCursor()); |
| 3506 | var increment = forward ? 1 : -1; |
| 3507 | var endLine = forward ? cm.lineCount() : -1; |
| 3508 | var curCh = cur.ch; |
| 3509 | var line = cur.line; |
| 3510 | var lineText = cm.getLine(line); |
| 3511 | var state = { |
| 3512 | lineText: lineText, |
| 3513 | nextCh: lineText.charAt(curCh), |
| 3514 | lastCh: null, |
| 3515 | index: curCh, |
| 3516 | symb: symb, |
| 3517 | reverseSymb: (forward ? { ')': '(', '}': '{' } : { '(': ')', '{': '}' })[symb], |
| 3518 | forward: forward, |
| 3519 | depth: 0, |
| 3520 | curMoveThrough: false |
| 3521 | }; |
| 3522 | var mode = symbolToMode[symb]; |
| 3523 | if (!mode)return cur; |
| 3524 | var init = findSymbolModes[mode].init; |
| 3525 | var isComplete = findSymbolModes[mode].isComplete; |
| 3526 | if (init) { init(state); } |
| 3527 | while (line !== endLine && repeat) { |
| 3528 | state.index += increment; |
| 3529 | state.nextCh = state.lineText.charAt(state.index); |
| 3530 | if (!state.nextCh) { |
| 3531 | line += increment; |
| 3532 | state.lineText = cm.getLine(line) || ''; |
| 3533 | if (increment > 0) { |
| 3534 | state.index = 0; |
| 3535 | } else { |
| 3536 | var lineLen = state.lineText.length; |
| 3537 | state.index = (lineLen > 0) ? (lineLen-1) : 0; |
| 3538 | } |
| 3539 | state.nextCh = state.lineText.charAt(state.index); |
| 3540 | } |
| 3541 | if (isComplete(state)) { |
| 3542 | cur.line = line; |
| 3543 | cur.ch = state.index; |
| 3544 | repeat--; |
| 3545 | } |
| 3546 | } |
| 3547 | if (state.nextCh || state.curMoveThrough) { |
| 3548 | return Pos(line, state.index); |
| 3549 | } |
| 3550 | return cur; |
| 3551 | } |
| 3552 | |
| 3553 | /* |
| 3554 | * Returns the boundaries of the next word. If the cursor in the middle of |
no test coverage detected