* Clips cursor to ensure that line is within the buffer's range * If includeLineBreak is true, then allow cur.ch == lineLength.
(cm, cur)
| 2914 | * If includeLineBreak is true, then allow cur.ch == lineLength. |
| 2915 | */ |
| 2916 | function clipCursorToContent(cm, cur) { |
| 2917 | var vim = cm.state.vim; |
| 2918 | var includeLineBreak = vim.insertMode || vim.visualMode; |
| 2919 | var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() ); |
| 2920 | var maxCh = lineLength(cm, line) - 1 + !!includeLineBreak; |
| 2921 | var ch = Math.min(Math.max(0, cur.ch), maxCh); |
| 2922 | return Pos(line, ch); |
| 2923 | } |
| 2924 | function copyArgs(args) { |
| 2925 | var ret = {}; |
| 2926 | for (var prop in args) { |
no test coverage detected