| 12391 | } |
| 12392 | |
| 12393 | function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) { |
| 12394 | var cur = getHead(cm); |
| 12395 | var line = cm.getLine(cur.line); |
| 12396 | var idx = cur.ch; |
| 12397 | |
| 12398 | // Seek to first word or non-whitespace character, depending on if |
| 12399 | // noSymbol is true. |
| 12400 | var test = noSymbol ? wordCharTest[0] : bigWordCharTest [0]; |
| 12401 | while (!test(line.charAt(idx))) { |
| 12402 | idx++; |
| 12403 | if (idx >= line.length) { return null; } |
| 12404 | } |
| 12405 | |
| 12406 | if (bigWord) { |
| 12407 | test = bigWordCharTest[0]; |
| 12408 | } else { |
| 12409 | test = wordCharTest[0]; |
| 12410 | if (!test(line.charAt(idx))) { |
| 12411 | test = wordCharTest[1]; |
| 12412 | } |
| 12413 | } |
| 12414 | |
| 12415 | var end = idx, start = idx; |
| 12416 | while (test(line.charAt(end)) && end < line.length) { end++; } |
| 12417 | while (test(line.charAt(start)) && start >= 0) { start--; } |
| 12418 | start++; |
| 12419 | |
| 12420 | if (inclusive) { |
| 12421 | // If present, include all whitespace after word. |
| 12422 | // Otherwise, include all whitespace before word, except indentation. |
| 12423 | var wordEnd = end; |
| 12424 | while (/\s/.test(line.charAt(end)) && end < line.length) { end++; } |
| 12425 | if (wordEnd == end) { |
| 12426 | var wordStart = start; |
| 12427 | while (/\s/.test(line.charAt(start - 1)) && start > 0) { start--; } |
| 12428 | if (!start) { start = wordStart; } |
| 12429 | } |
| 12430 | } |
| 12431 | return { start: Pos(cur.line, start), end: Pos(cur.line, end) }; |
| 12432 | } |
| 12433 | |
| 12434 | function recordJumpPosition(cm, oldCur, newCur) { |
| 12435 | if (!cursorEqual(oldCur, newCur)) { |