(cm, curStart, curEnd)
| 12348 | // 'dw' should word, but not the newline, while 'w' should advance the |
| 12349 | // caret to the first character of the next line. |
| 12350 | function clipToLine(cm, curStart, curEnd) { |
| 12351 | var selection = cm.getRange(curStart, curEnd); |
| 12352 | // Only clip if the selection ends with trailing newline + whitespace |
| 12353 | if (/\n\s*$/.test(selection)) { |
| 12354 | var lines = selection.split('\n'); |
| 12355 | // We know this is all whitespace. |
| 12356 | lines.pop(); |
| 12357 | |
| 12358 | // Cases: |
| 12359 | // 1. Last word is an empty line - do not clip the trailing '\n' |
| 12360 | // 2. Last word is not an empty line - clip the trailing '\n' |
| 12361 | var line; |
| 12362 | // Find the line containing the last word, and clip all whitespace up |
| 12363 | // to it. |
| 12364 | for (var line = lines.pop(); lines.length > 0 && line && isWhiteSpaceString(line); line = lines.pop()) { |
| 12365 | curEnd.line--; |
| 12366 | curEnd.ch = 0; |
| 12367 | } |
| 12368 | // If the last word is not an empty line, clip an additional newline |
| 12369 | if (line) { |
| 12370 | curEnd.line--; |
| 12371 | curEnd.ch = lineLength(cm, curEnd.line); |
| 12372 | } else { |
| 12373 | curEnd.ch = 0; |
| 12374 | } |
| 12375 | } |
| 12376 | } |
| 12377 | |
| 12378 | // Expand the selection to line ends. |
| 12379 | function expandSelectionToLine(_cm, curStart, curEnd) { |
no test coverage detected