codemirror-rails 3.24 → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +3001 -1798
- data/vendor/assets/javascripts/codemirror/addons/comment/comment.js +24 -4
- data/vendor/assets/javascripts/codemirror/addons/comment/continuecomment.js +47 -32
- data/vendor/assets/javascripts/codemirror/addons/dialog/dialog.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/fullscreen.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/placeholder.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/display/rulers.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/edit/closebrackets.js +76 -37
- data/vendor/assets/javascripts/codemirror/addons/edit/closetag.js +59 -37
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +25 -17
- data/vendor/assets/javascripts/codemirror/addons/edit/matchbrackets.js +67 -46
- data/vendor/assets/javascripts/codemirror/addons/edit/matchtags.js +10 -3
- data/vendor/assets/javascripts/codemirror/addons/edit/trailingspace.js +23 -14
- data/vendor/assets/javascripts/codemirror/addons/fold/brace-fold.js +12 -3
- data/vendor/assets/javascripts/codemirror/addons/fold/comment-fold.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/foldcode.js +28 -3
- data/vendor/assets/javascripts/codemirror/addons/fold/foldgutter.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/fold/indent-fold.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/fold/markdown-fold.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/fold/xml-fold.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/anyword-hint.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/css-hint.js +10 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/html-hint.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/javascript-hint.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/python-hint.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +10 -4
- data/vendor/assets/javascripts/codemirror/addons/hint/sql-hint.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/hint/xml-hint.js +22 -34
- data/vendor/assets/javascripts/codemirror/addons/lint/coffeescript-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/css-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +9 -4
- data/vendor/assets/javascripts/codemirror/addons/lint/json-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/lint/lint.js +12 -8
- data/vendor/assets/javascripts/codemirror/addons/lint/yaml-lint.js +12 -1
- data/vendor/assets/javascripts/codemirror/addons/merge/merge.js +18 -16
- data/vendor/assets/javascripts/codemirror/addons/mode/loadmode.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/mode/overlay.js +15 -10
- data/vendor/assets/javascripts/codemirror/addons/runmode/colorize.js +11 -3
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode-standalone.js +0 -2
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.js +12 -0
- data/vendor/assets/javascripts/codemirror/addons/runmode/runmode.node.js +4 -0
- data/vendor/assets/javascripts/codemirror/addons/scroll/scrollpastend.js +9 -2
- data/vendor/assets/javascripts/codemirror/addons/search/match-highlighter.js +12 -3
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +24 -16
- data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +21 -2
- data/vendor/assets/javascripts/codemirror/addons/selection/active-line.js +38 -17
- data/vendor/assets/javascripts/codemirror/addons/selection/mark-selection.js +16 -9
- data/vendor/assets/javascripts/codemirror/addons/tern/tern.js +33 -5
- data/vendor/assets/javascripts/codemirror/addons/wrap/hardwrap.js +27 -2
- data/vendor/assets/javascripts/codemirror/keymaps/emacs.js +12 -5
- data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +505 -0
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +138 -179
- data/vendor/assets/javascripts/codemirror/modes/apl.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/asterisk.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/clike.js +15 -4
- data/vendor/assets/javascripts/codemirror/modes/clojure.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/cobol.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/coffeescript.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/commonlisp.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/css.js +18 -27
- data/vendor/assets/javascripts/codemirror/modes/d.js +12 -2
- data/vendor/assets/javascripts/codemirror/modes/diff.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/dtd.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ecl.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/eiffel.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/erlang.js +13 -1
- data/vendor/assets/javascripts/codemirror/modes/fortran.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gas.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gfm.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/gherkin.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/go.js +12 -1
- data/vendor/assets/javascripts/codemirror/modes/groovy.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haskell.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/haxe.js +18 -9
- data/vendor/assets/javascripts/codemirror/modes/htmlembedded.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/htmlmixed.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/http.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/jade.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +23 -16
- data/vendor/assets/javascripts/codemirror/modes/jinja2.js +53 -118
- data/vendor/assets/javascripts/codemirror/modes/julia.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/livescript.js +17 -4
- data/vendor/assets/javascripts/codemirror/modes/lua.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/mirc.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/mllike.js +12 -1
- data/vendor/assets/javascripts/codemirror/modes/nginx.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ntriples.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/octave.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/pascal.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/pegjs.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/perl.js +84 -73
- data/vendor/assets/javascripts/codemirror/modes/php.js +20 -101
- data/vendor/assets/javascripts/codemirror/modes/pig.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/properties.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/puppet.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +21 -11
- data/vendor/assets/javascripts/codemirror/modes/q.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/r.js +13 -3
- data/vendor/assets/javascripts/codemirror/modes/{rpm-spec.js → rpm.js} +34 -2
- data/vendor/assets/javascripts/codemirror/modes/rst.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/ruby.js +11 -0
- data/vendor/assets/javascripts/codemirror/modes/rust.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sass.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/scheme.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/shell.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sieve.js +11 -4
- data/vendor/assets/javascripts/codemirror/modes/smalltalk.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/smartymixed.js +14 -2
- data/vendor/assets/javascripts/codemirror/modes/solr.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sparql.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/sql.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/stex.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/tcl.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/tiddlywiki.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/tiki.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/toml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/turtle.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/vb.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/vbscript.js +13 -0
- data/vendor/assets/javascripts/codemirror/modes/velocity.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/verilog.js +89 -236
- data/vendor/assets/javascripts/codemirror/modes/xml.js +41 -60
- data/vendor/assets/javascripts/codemirror/modes/xquery.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/yaml.js +12 -0
- data/vendor/assets/javascripts/codemirror/modes/z80.js +12 -0
- data/vendor/assets/stylesheets/codemirror.css +15 -10
- data/vendor/assets/stylesheets/codemirror/themes/ambiance.css +1 -0
- data/vendor/assets/stylesheets/codemirror/themes/lesser-dark.css +4 -0
- data/vendor/assets/stylesheets/codemirror/themes/mdn-like.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/pastel-on-dark.css +1 -0
- data/vendor/assets/stylesheets/codemirror/themes/rubyblue.css +2 -0
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +17 -3
- metadata +20 -25
- data/vendor/assets/javascripts/codemirror/keymaps/extra.js +0 -43
- data/vendor/assets/javascripts/codemirror/modes/django.js +0 -55
- data/vendor/assets/javascripts/codemirror/modes/dylan.js +0 -284
- data/vendor/assets/javascripts/codemirror/modes/less.js +0 -347
- data/vendor/assets/javascripts/codemirror/modes/rpm-changes.js +0 -19
- data/vendor/assets/stylesheets/codemirror/modes/rpm-spec.css +0 -5
@@ -56,7 +56,14 @@
|
|
56
56
|
* 8. Set up Vim to work as a keymap for CodeMirror.
|
57
57
|
*/
|
58
58
|
|
59
|
-
(function() {
|
59
|
+
(function(mod) {
|
60
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
61
|
+
mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/dialog/dialog"));
|
62
|
+
else if (typeof define == "function" && define.amd) // AMD
|
63
|
+
define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/dialog/dialog"], mod);
|
64
|
+
else // Plain browser env
|
65
|
+
mod(CodeMirror);
|
66
|
+
})(function(CodeMirror) {
|
60
67
|
'use strict';
|
61
68
|
|
62
69
|
var defaultKeymap = [
|
@@ -194,7 +201,7 @@
|
|
194
201
|
{ keys: [','], type: 'motion', motion: 'repeatLastCharacterSearch',
|
195
202
|
motionArgs: { forward: false }},
|
196
203
|
{ keys: ['\'', 'character'], type: 'motion', motion: 'goToMark',
|
197
|
-
motionArgs: {toJumplist: true
|
204
|
+
motionArgs: {toJumplist: true}},
|
198
205
|
{ keys: ['`', 'character'], type: 'motion', motion: 'goToMark',
|
199
206
|
motionArgs: {toJumplist: true}},
|
200
207
|
{ keys: [']', '`'], type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } },
|
@@ -322,15 +329,15 @@
|
|
322
329
|
{ keys: ['?'], type: 'search',
|
323
330
|
searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }},
|
324
331
|
{ keys: ['*'], type: 'search',
|
325
|
-
searchArgs: { forward: true, querySrc: 'wordUnderCursor',
|
332
|
+
searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }},
|
326
333
|
{ keys: ['#'], type: 'search',
|
327
|
-
searchArgs: { forward: false, querySrc: 'wordUnderCursor',
|
328
|
-
{ keys: ['g', '*'], type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }},
|
329
|
-
{ keys: ['g', '#'], type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }},
|
334
|
+
searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }},
|
330
335
|
// Ex command
|
331
336
|
{ keys: [':'], type: 'ex' }
|
332
337
|
];
|
333
338
|
|
339
|
+
var Pos = CodeMirror.Pos;
|
340
|
+
|
334
341
|
var Vim = function() {
|
335
342
|
CodeMirror.defineOption('vimMode', false, function(cm, val) {
|
336
343
|
if (val) {
|
@@ -348,13 +355,16 @@
|
|
348
355
|
cm.state.vim = null;
|
349
356
|
}
|
350
357
|
});
|
351
|
-
function beforeSelectionChange(cm,
|
358
|
+
function beforeSelectionChange(cm, obj) {
|
352
359
|
var vim = cm.state.vim;
|
353
360
|
if (vim.insertMode || vim.exMode) return;
|
354
361
|
|
355
|
-
var head =
|
362
|
+
var head = obj.ranges[0].head;
|
363
|
+
var anchor = obj.ranges[0].anchor;
|
356
364
|
if (head.ch && head.ch == cm.doc.getLine(head.line).length) {
|
357
|
-
head.ch
|
365
|
+
var pos = Pos(head.line, head.ch - 1);
|
366
|
+
obj.update([{anchor: cursorEqual(head, anchor) ? pos : anchor,
|
367
|
+
head: pos}]);
|
358
368
|
}
|
359
369
|
}
|
360
370
|
function getOnPasteFn(cm) {
|
@@ -386,7 +396,7 @@
|
|
386
396
|
var specialKeys = ['Left', 'Right', 'Up', 'Down', 'Space', 'Backspace',
|
387
397
|
'Esc', 'Home', 'End', 'PageUp', 'PageDown', 'Enter'];
|
388
398
|
var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']);
|
389
|
-
var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"'
|
399
|
+
var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"']);
|
390
400
|
|
391
401
|
function isLine(cm, line) {
|
392
402
|
return line >= cm.firstLine() && line <= cm.lastLine();
|
@@ -539,7 +549,6 @@
|
|
539
549
|
this.latestRegister = undefined;
|
540
550
|
this.isPlaying = false;
|
541
551
|
this.isRecording = false;
|
542
|
-
this.replaySearchQueries = [];
|
543
552
|
this.onRecordingDone = undefined;
|
544
553
|
this.lastInsertModeChanges = createInsertModeChanges();
|
545
554
|
}
|
@@ -605,8 +614,6 @@
|
|
605
614
|
searchQuery: null,
|
606
615
|
// Whether we are searching backwards.
|
607
616
|
searchIsReversed: false,
|
608
|
-
// Replace part of the last substituted pattern
|
609
|
-
lastSubstituteReplacePart: undefined,
|
610
617
|
jumpList: createCircularJumpList(),
|
611
618
|
macroModeState: new MacroModeState,
|
612
619
|
// Recording latest f, t, F or T motion command.
|
@@ -757,7 +764,6 @@
|
|
757
764
|
this.clear();
|
758
765
|
this.keyBuffer = [text || ''];
|
759
766
|
this.insertModeChanges = [];
|
760
|
-
this.searchQueries = [];
|
761
767
|
this.linewise = !!linewise;
|
762
768
|
}
|
763
769
|
Register.prototype = {
|
@@ -776,13 +782,9 @@
|
|
776
782
|
pushInsertModeChanges: function(changes) {
|
777
783
|
this.insertModeChanges.push(createInsertModeChanges(changes));
|
778
784
|
},
|
779
|
-
pushSearchQuery: function(query) {
|
780
|
-
this.searchQueries.push(query);
|
781
|
-
},
|
782
785
|
clear: function() {
|
783
786
|
this.keyBuffer = [];
|
784
787
|
this.insertModeChanges = [];
|
785
|
-
this.searchQueries = [];
|
786
788
|
this.linewise = false;
|
787
789
|
},
|
788
790
|
toString: function() {
|
@@ -801,8 +803,6 @@
|
|
801
803
|
function RegisterController(registers) {
|
802
804
|
this.registers = registers;
|
803
805
|
this.unnamedRegister = registers['"'] = new Register();
|
804
|
-
registers['.'] = new Register();
|
805
|
-
registers[':'] = new Register();
|
806
806
|
}
|
807
807
|
RegisterController.prototype = {
|
808
808
|
pushText: function(registerName, operator, text, linewise) {
|
@@ -1056,7 +1056,6 @@
|
|
1056
1056
|
return;
|
1057
1057
|
}
|
1058
1058
|
var forward = command.searchArgs.forward;
|
1059
|
-
var wholeWordOnly = command.searchArgs.wholeWordOnly;
|
1060
1059
|
getSearchState(cm).setReversed(!forward);
|
1061
1060
|
var promptPrefix = (forward) ? '/' : '?';
|
1062
1061
|
var originalQuery = getSearchState(cm).getQuery();
|
@@ -1077,10 +1076,6 @@
|
|
1077
1076
|
function onPromptClose(query) {
|
1078
1077
|
cm.scrollTo(originalScrollPos.left, originalScrollPos.top);
|
1079
1078
|
handleQuery(query, true /** ignoreCase */, true /** smartCase */);
|
1080
|
-
var macroModeState = vimGlobalState.macroModeState;
|
1081
|
-
if (macroModeState.isRecording) {
|
1082
|
-
logSearchQuery(macroModeState, query);
|
1083
|
-
}
|
1084
1079
|
}
|
1085
1080
|
function onPromptKeyUp(_e, query) {
|
1086
1081
|
var parsedQuery;
|
@@ -1111,19 +1106,13 @@
|
|
1111
1106
|
}
|
1112
1107
|
switch (command.searchArgs.querySrc) {
|
1113
1108
|
case 'prompt':
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
prefix: promptPrefix,
|
1122
|
-
desc: searchPromptDesc,
|
1123
|
-
onKeyUp: onPromptKeyUp,
|
1124
|
-
onKeyDown: onPromptKeyDown
|
1125
|
-
});
|
1126
|
-
}
|
1109
|
+
showPrompt(cm, {
|
1110
|
+
onClose: onPromptClose,
|
1111
|
+
prefix: promptPrefix,
|
1112
|
+
desc: searchPromptDesc,
|
1113
|
+
onKeyUp: onPromptKeyUp,
|
1114
|
+
onKeyDown: onPromptKeyDown
|
1115
|
+
});
|
1127
1116
|
break;
|
1128
1117
|
case 'wordUnderCursor':
|
1129
1118
|
var word = expandWordUnderCursor(cm, false /** inclusive */,
|
@@ -1141,8 +1130,8 @@
|
|
1141
1130
|
}
|
1142
1131
|
var query = cm.getLine(word.start.line).substring(word.start.ch,
|
1143
1132
|
word.end.ch);
|
1144
|
-
if (isKeyword
|
1145
|
-
|
1133
|
+
if (isKeyword) {
|
1134
|
+
query = '\\b' + query + '\\b';
|
1146
1135
|
} else {
|
1147
1136
|
query = escapeRegex(query);
|
1148
1137
|
}
|
@@ -1193,8 +1182,8 @@
|
|
1193
1182
|
var operator = inputState.operator;
|
1194
1183
|
var operatorArgs = inputState.operatorArgs || {};
|
1195
1184
|
var registerName = inputState.registerName;
|
1196
|
-
var selectionEnd = cm.getCursor('head');
|
1197
|
-
var selectionStart = cm.getCursor('anchor');
|
1185
|
+
var selectionEnd = copyCursor(cm.getCursor('head'));
|
1186
|
+
var selectionStart = copyCursor(cm.getCursor('anchor'));
|
1198
1187
|
// The difference between cur and selection cursors are that cur is
|
1199
1188
|
// being operated on and ignores that there is a selection.
|
1200
1189
|
var curStart = copyCursor(selectionEnd);
|
@@ -1250,7 +1239,7 @@
|
|
1250
1239
|
}
|
1251
1240
|
// TODO: Handle null returns from motion commands better.
|
1252
1241
|
if (!curEnd) {
|
1253
|
-
curEnd =
|
1242
|
+
curEnd = Pos(curStart.line, curStart.ch);
|
1254
1243
|
}
|
1255
1244
|
if (vim.visualMode) {
|
1256
1245
|
// Check if the selection crossed over itself. Will need to shift
|
@@ -1354,22 +1343,22 @@
|
|
1354
1343
|
var motions = {
|
1355
1344
|
moveToTopLine: function(cm, motionArgs) {
|
1356
1345
|
var line = getUserVisibleLines(cm).top + motionArgs.repeat -1;
|
1357
|
-
return
|
1346
|
+
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1358
1347
|
},
|
1359
1348
|
moveToMiddleLine: function(cm) {
|
1360
1349
|
var range = getUserVisibleLines(cm);
|
1361
1350
|
var line = Math.floor((range.top + range.bottom) * 0.5);
|
1362
|
-
return
|
1351
|
+
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1363
1352
|
},
|
1364
1353
|
moveToBottomLine: function(cm, motionArgs) {
|
1365
1354
|
var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1;
|
1366
|
-
return
|
1355
|
+
return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line)));
|
1367
1356
|
},
|
1368
1357
|
expandToLine: function(cm, motionArgs) {
|
1369
1358
|
// Expands forward to end of line, and then to next line if repeat is
|
1370
1359
|
// >1. Does not handle backward motion!
|
1371
1360
|
var cur = cm.getCursor();
|
1372
|
-
return
|
1361
|
+
return Pos(cur.line + motionArgs.repeat - 1, Infinity);
|
1373
1362
|
},
|
1374
1363
|
findNext: function(cm, motionArgs) {
|
1375
1364
|
var state = getSearchState(cm);
|
@@ -1383,11 +1372,10 @@
|
|
1383
1372
|
highlightSearchMatches(cm, query);
|
1384
1373
|
return findNext(cm, prev/** prev */, query, motionArgs.repeat);
|
1385
1374
|
},
|
1386
|
-
goToMark: function(
|
1375
|
+
goToMark: function(_cm, motionArgs, vim) {
|
1387
1376
|
var mark = vim.marks[motionArgs.selectedCharacter];
|
1388
1377
|
if (mark) {
|
1389
|
-
|
1390
|
-
return motionArgs.linewise ? { line: pos.line, ch: findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line)) } : pos;
|
1378
|
+
return mark.find();
|
1391
1379
|
}
|
1392
1380
|
return null;
|
1393
1381
|
},
|
@@ -1435,7 +1423,7 @@
|
|
1435
1423
|
// Vim places the cursor on the first non-whitespace character of
|
1436
1424
|
// the line if there is one, else it places the cursor at the end
|
1437
1425
|
// of the line, regardless of whether a mark was found.
|
1438
|
-
best
|
1426
|
+
best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line)));
|
1439
1427
|
}
|
1440
1428
|
return best;
|
1441
1429
|
},
|
@@ -1443,7 +1431,7 @@
|
|
1443
1431
|
var cur = cm.getCursor();
|
1444
1432
|
var repeat = motionArgs.repeat;
|
1445
1433
|
var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat;
|
1446
|
-
return
|
1434
|
+
return Pos(cur.line, ch);
|
1447
1435
|
},
|
1448
1436
|
moveByLines: function(cm, motionArgs, vim) {
|
1449
1437
|
var cur = cm.getCursor();
|
@@ -1478,8 +1466,8 @@
|
|
1478
1466
|
endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
|
1479
1467
|
vim.lastHPos = endCh;
|
1480
1468
|
}
|
1481
|
-
vim.lastHSPos = cm.charCoords(
|
1482
|
-
return
|
1469
|
+
vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left;
|
1470
|
+
return Pos(line, endCh);
|
1483
1471
|
},
|
1484
1472
|
moveByDisplayLines: function(cm, motionArgs, vim) {
|
1485
1473
|
var cur = cm.getCursor();
|
@@ -1501,7 +1489,7 @@
|
|
1501
1489
|
var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos };
|
1502
1490
|
var res = cm.coordsChar(goalCoords, 'div');
|
1503
1491
|
} else {
|
1504
|
-
var resCoords = cm.charCoords(
|
1492
|
+
var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div');
|
1505
1493
|
resCoords.left = vim.lastHSPos;
|
1506
1494
|
res = cm.coordsChar(resCoords, 'div');
|
1507
1495
|
}
|
@@ -1534,7 +1522,7 @@
|
|
1534
1522
|
line += inc;
|
1535
1523
|
}
|
1536
1524
|
}
|
1537
|
-
return
|
1525
|
+
return Pos(line, 0);
|
1538
1526
|
},
|
1539
1527
|
moveByScroll: function(cm, motionArgs, vim) {
|
1540
1528
|
var scrollbox = cm.getScrollInfo();
|
@@ -1588,7 +1576,7 @@
|
|
1588
1576
|
moveToEol: function(cm, motionArgs, vim) {
|
1589
1577
|
var cur = cm.getCursor();
|
1590
1578
|
vim.lastHPos = Infinity;
|
1591
|
-
var retval=
|
1579
|
+
var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity);
|
1592
1580
|
var end=cm.clipPos(retval);
|
1593
1581
|
end.ch--;
|
1594
1582
|
vim.lastHSPos = cm.charCoords(end,'div').left;
|
@@ -1598,8 +1586,8 @@
|
|
1598
1586
|
// Go to the start of the line where the text begins, or the end for
|
1599
1587
|
// whitespace-only lines
|
1600
1588
|
var cursor = cm.getCursor();
|
1601
|
-
return
|
1602
|
-
|
1589
|
+
return Pos(cursor.line,
|
1590
|
+
findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line)));
|
1603
1591
|
},
|
1604
1592
|
moveToMatchedSymbol: function(cm) {
|
1605
1593
|
var cursor = cm.getCursor();
|
@@ -1612,7 +1600,7 @@
|
|
1612
1600
|
do {
|
1613
1601
|
symbol = lineText.charAt(ch++);
|
1614
1602
|
if (symbol && isMatchableSymbol(symbol)) {
|
1615
|
-
var endContext = cm.getTokenAt(
|
1603
|
+
var endContext = cm.getTokenAt(Pos(line, ch)).type;
|
1616
1604
|
var endCtxLevel = getContextLevel(endContext);
|
1617
1605
|
if (startCtxLevel >= endCtxLevel) {
|
1618
1606
|
break;
|
@@ -1620,22 +1608,22 @@
|
|
1620
1608
|
}
|
1621
1609
|
} while (symbol);
|
1622
1610
|
if (symbol) {
|
1623
|
-
return findMatchedSymbol(cm,
|
1611
|
+
return findMatchedSymbol(cm, Pos(line, ch-1), symbol);
|
1624
1612
|
} else {
|
1625
1613
|
return cursor;
|
1626
1614
|
}
|
1627
1615
|
},
|
1628
1616
|
moveToStartOfLine: function(cm) {
|
1629
1617
|
var cursor = cm.getCursor();
|
1630
|
-
return
|
1618
|
+
return Pos(cursor.line, 0);
|
1631
1619
|
},
|
1632
1620
|
moveToLineOrEdgeOfDocument: function(cm, motionArgs) {
|
1633
1621
|
var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine();
|
1634
1622
|
if (motionArgs.repeatIsExplicit) {
|
1635
1623
|
lineNum = motionArgs.repeat - cm.getOption('firstLineNumber');
|
1636
1624
|
}
|
1637
|
-
return
|
1638
|
-
|
1625
|
+
return Pos(lineNum,
|
1626
|
+
findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum)));
|
1639
1627
|
},
|
1640
1628
|
textObjectManipulation: function(cm, motionArgs) {
|
1641
1629
|
// TODO: lots of possible exceptions that can be thrown here. Try da(
|
@@ -1802,7 +1790,7 @@
|
|
1802
1790
|
var top = cm.getScrollInfo().top;
|
1803
1791
|
var delta = lineHeight * repeat;
|
1804
1792
|
var newPos = actionArgs.forward ? top + delta : top - delta;
|
1805
|
-
var cursor = cm.getCursor();
|
1793
|
+
var cursor = copyCursor(cm.getCursor());
|
1806
1794
|
var cursorCoords = cm.charCoords(cursor, 'local');
|
1807
1795
|
if (actionArgs.forward) {
|
1808
1796
|
if (newPos > cursorCoords.top) {
|
@@ -1832,7 +1820,7 @@
|
|
1832
1820
|
},
|
1833
1821
|
scrollToCursor: function(cm, actionArgs) {
|
1834
1822
|
var lineNum = cm.getCursor().line;
|
1835
|
-
var charCoords = cm.charCoords(
|
1823
|
+
var charCoords = cm.charCoords(Pos(lineNum, 0), 'local');
|
1836
1824
|
var height = cm.getScrollInfo().clientHeight;
|
1837
1825
|
var y = charCoords.top;
|
1838
1826
|
var lineHeight = charCoords.bottom - y;
|
@@ -1869,7 +1857,7 @@
|
|
1869
1857
|
var insertAt = (actionArgs) ? actionArgs.insertAt : null;
|
1870
1858
|
if (insertAt == 'eol') {
|
1871
1859
|
var cursor = cm.getCursor();
|
1872
|
-
cursor =
|
1860
|
+
cursor = Pos(cursor.line, lineLength(cm, cursor.line));
|
1873
1861
|
cm.setCursor(cursor);
|
1874
1862
|
} else if (insertAt == 'charAfter') {
|
1875
1863
|
cm.setCursor(offsetCursor(cm.getCursor(), 0, 1));
|
@@ -1907,15 +1895,13 @@
|
|
1907
1895
|
vim.visualLine = !!actionArgs.linewise;
|
1908
1896
|
if (vim.visualLine) {
|
1909
1897
|
curStart.ch = 0;
|
1910
|
-
curEnd = clipCursorToContent(
|
1911
|
-
|
1912
|
-
|
1913
|
-
}, true /** includeLineBreak */);
|
1898
|
+
curEnd = clipCursorToContent(
|
1899
|
+
cm, Pos(curStart.line + repeat - 1, lineLength(cm, curStart.line)),
|
1900
|
+
true /** includeLineBreak */);
|
1914
1901
|
} else {
|
1915
|
-
curEnd = clipCursorToContent(
|
1916
|
-
|
1917
|
-
|
1918
|
-
}, true /** includeLineBreak */);
|
1902
|
+
curEnd = clipCursorToContent(
|
1903
|
+
cm, Pos(curStart.line, curStart.ch + repeat),
|
1904
|
+
true /** includeLineBreak */);
|
1919
1905
|
}
|
1920
1906
|
// Make the initial selection.
|
1921
1907
|
if (!actionArgs.repeatIsExplicit && !vim.visualLine) {
|
@@ -1980,29 +1966,29 @@
|
|
1980
1966
|
// Repeat is the number of lines to join. Minimum 2 lines.
|
1981
1967
|
var repeat = Math.max(actionArgs.repeat, 2);
|
1982
1968
|
curStart = cm.getCursor();
|
1983
|
-
curEnd = clipCursorToContent(cm,
|
1984
|
-
|
1969
|
+
curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1,
|
1970
|
+
Infinity));
|
1985
1971
|
}
|
1986
1972
|
var finalCh = 0;
|
1987
1973
|
cm.operation(function() {
|
1988
1974
|
for (var i = curStart.line; i < curEnd.line; i++) {
|
1989
1975
|
finalCh = lineLength(cm, curStart.line);
|
1990
|
-
var tmp =
|
1991
|
-
|
1976
|
+
var tmp = Pos(curStart.line + 1,
|
1977
|
+
lineLength(cm, curStart.line + 1));
|
1992
1978
|
var text = cm.getRange(curStart, tmp);
|
1993
1979
|
text = text.replace(/\n\s*/g, ' ');
|
1994
1980
|
cm.replaceRange(text, curStart, tmp);
|
1995
1981
|
}
|
1996
|
-
var curFinalPos =
|
1982
|
+
var curFinalPos = Pos(curStart.line, finalCh);
|
1997
1983
|
cm.setCursor(curFinalPos);
|
1998
1984
|
});
|
1999
1985
|
},
|
2000
1986
|
newLineAndEnterInsertMode: function(cm, actionArgs, vim) {
|
2001
1987
|
vim.insertMode = true;
|
2002
|
-
var insertAt = cm.getCursor();
|
1988
|
+
var insertAt = copyCursor(cm.getCursor());
|
2003
1989
|
if (insertAt.line === cm.firstLine() && !actionArgs.after) {
|
2004
1990
|
// Special case for inserting newline before start of document.
|
2005
|
-
cm.replaceRange('\n',
|
1991
|
+
cm.replaceRange('\n', Pos(cm.firstLine(), 0));
|
2006
1992
|
cm.setCursor(cm.firstLine(), 0);
|
2007
1993
|
} else {
|
2008
1994
|
insertAt.line = (actionArgs.after) ? insertAt.line :
|
@@ -2016,7 +2002,7 @@
|
|
2016
2002
|
this.enterInsertMode(cm, { repeat: actionArgs.repeat }, vim);
|
2017
2003
|
},
|
2018
2004
|
paste: function(cm, actionArgs) {
|
2019
|
-
var cur = cm.getCursor();
|
2005
|
+
var cur = copyCursor(cm.getCursor());
|
2020
2006
|
var register = vimGlobalState.registerController.getRegister(
|
2021
2007
|
actionArgs.registerName);
|
2022
2008
|
var text = register.toString();
|
@@ -2044,11 +2030,13 @@
|
|
2044
2030
|
var curPosFinal;
|
2045
2031
|
var idx;
|
2046
2032
|
if (linewise && actionArgs.after) {
|
2047
|
-
curPosFinal =
|
2048
|
-
|
2033
|
+
curPosFinal = Pos(
|
2034
|
+
cur.line + 1,
|
2035
|
+
findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1)));
|
2049
2036
|
} else if (linewise && !actionArgs.after) {
|
2050
|
-
curPosFinal =
|
2051
|
-
|
2037
|
+
curPosFinal = Pos(
|
2038
|
+
cur.line,
|
2039
|
+
findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line)));
|
2052
2040
|
} else if (!linewise && actionArgs.after) {
|
2053
2041
|
idx = cm.indexFromPos(cur);
|
2054
2042
|
curPosFinal = cm.posFromIndex(idx + text.length - 1);
|
@@ -2084,14 +2072,14 @@
|
|
2084
2072
|
curEnd=cm.getCursor('end');
|
2085
2073
|
// workaround to catch the character under the cursor
|
2086
2074
|
// existing workaround doesn't cover actions
|
2087
|
-
curEnd=cm.clipPos(
|
2075
|
+
curEnd=cm.clipPos(Pos(curEnd.line, curEnd.ch+1));
|
2088
2076
|
}else{
|
2089
2077
|
var line = cm.getLine(curStart.line);
|
2090
2078
|
replaceTo = curStart.ch + actionArgs.repeat;
|
2091
2079
|
if (replaceTo > line.length) {
|
2092
2080
|
replaceTo=line.length;
|
2093
2081
|
}
|
2094
|
-
curEnd =
|
2082
|
+
curEnd = Pos(curStart.line, replaceTo);
|
2095
2083
|
}
|
2096
2084
|
if (replaceWith=='\n'){
|
2097
2085
|
if (!vim.visualMode) cm.replaceRange('', curStart, curEnd);
|
@@ -2129,14 +2117,14 @@
|
|
2129
2117
|
if (token) {
|
2130
2118
|
var increment = actionArgs.increase ? 1 : -1;
|
2131
2119
|
var number = parseInt(token) + (increment * actionArgs.repeat);
|
2132
|
-
var from =
|
2133
|
-
var to =
|
2120
|
+
var from = Pos(cur.line, start);
|
2121
|
+
var to = Pos(cur.line, end);
|
2134
2122
|
numberStr = number.toString();
|
2135
2123
|
cm.replaceRange(numberStr, from, to);
|
2136
2124
|
} else {
|
2137
2125
|
return;
|
2138
2126
|
}
|
2139
|
-
cm.setCursor(
|
2127
|
+
cm.setCursor(Pos(cur.line, start + numberStr.length - 1));
|
2140
2128
|
},
|
2141
2129
|
repeatLastEdit: function(cm, actionArgs, vim) {
|
2142
2130
|
var lastEditInputState = vim.lastEditInputState;
|
@@ -2164,7 +2152,7 @@
|
|
2164
2152
|
var maxCh = lineLength(cm, line) - 1;
|
2165
2153
|
maxCh = (includeLineBreak) ? maxCh + 1 : maxCh;
|
2166
2154
|
var ch = Math.min(Math.max(0, cur.ch), maxCh);
|
2167
|
-
return
|
2155
|
+
return Pos(line, ch);
|
2168
2156
|
}
|
2169
2157
|
function copyArgs(args) {
|
2170
2158
|
var ret = {};
|
@@ -2176,7 +2164,7 @@
|
|
2176
2164
|
return ret;
|
2177
2165
|
}
|
2178
2166
|
function offsetCursor(cur, offsetLine, offsetCh) {
|
2179
|
-
return
|
2167
|
+
return Pos(cur.line + offsetLine, cur.ch + offsetCh);
|
2180
2168
|
}
|
2181
2169
|
function matchKeysPartial(pressed, mapped) {
|
2182
2170
|
for (var i = 0; i < pressed.length; i++) {
|
@@ -2195,7 +2183,7 @@
|
|
2195
2183
|
};
|
2196
2184
|
}
|
2197
2185
|
function copyCursor(cur) {
|
2198
|
-
return
|
2186
|
+
return Pos(cur.line, cur.ch);
|
2199
2187
|
}
|
2200
2188
|
function cursorEqual(cur1, cur2) {
|
2201
2189
|
return cur1.ch == cur2.ch && cur1.line == cur2.line;
|
@@ -2356,8 +2344,8 @@
|
|
2356
2344
|
}
|
2357
2345
|
}
|
2358
2346
|
|
2359
|
-
return { start:
|
2360
|
-
|
2347
|
+
return { start: Pos(cur.line, wordStart),
|
2348
|
+
end: Pos(cur.line, wordEnd) };
|
2361
2349
|
}
|
2362
2350
|
|
2363
2351
|
function recordJumpPosition(cm, oldCur, newCur) {
|
@@ -2445,7 +2433,7 @@
|
|
2445
2433
|
}
|
2446
2434
|
};
|
2447
2435
|
function findSymbol(cm, repeat, forward, symb) {
|
2448
|
-
var cur = cm.getCursor();
|
2436
|
+
var cur = copyCursor(cm.getCursor());
|
2449
2437
|
var increment = forward ? 1 : -1;
|
2450
2438
|
var endLine = forward ? cm.lineCount() : -1;
|
2451
2439
|
var curCh = cur.ch;
|
@@ -2488,7 +2476,7 @@
|
|
2488
2476
|
}
|
2489
2477
|
}
|
2490
2478
|
if (state.nextCh || state.curMoveThrough) {
|
2491
|
-
return
|
2479
|
+
return Pos(line, state.index);
|
2492
2480
|
}
|
2493
2481
|
return cur;
|
2494
2482
|
}
|
@@ -2602,7 +2590,7 @@
|
|
2602
2590
|
break;
|
2603
2591
|
}
|
2604
2592
|
words.push(word);
|
2605
|
-
cur =
|
2593
|
+
cur = Pos(word.line, forward ? (word.to - 1) : word.from);
|
2606
2594
|
}
|
2607
2595
|
var shortCircuit = words.length != repeat;
|
2608
2596
|
var firstWord = words[0];
|
@@ -2613,19 +2601,19 @@
|
|
2613
2601
|
// We did not start in the middle of a word. Discard the extra word at the end.
|
2614
2602
|
lastWord = words.pop();
|
2615
2603
|
}
|
2616
|
-
return
|
2604
|
+
return Pos(lastWord.line, lastWord.from);
|
2617
2605
|
} else if (forward && wordEnd) {
|
2618
|
-
return
|
2606
|
+
return Pos(lastWord.line, lastWord.to - 1);
|
2619
2607
|
} else if (!forward && wordEnd) {
|
2620
2608
|
// ge
|
2621
2609
|
if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) {
|
2622
2610
|
// We did not start in the middle of a word. Discard the extra word at the end.
|
2623
2611
|
lastWord = words.pop();
|
2624
2612
|
}
|
2625
|
-
return
|
2613
|
+
return Pos(lastWord.line, lastWord.to);
|
2626
2614
|
} else {
|
2627
2615
|
// b
|
2628
|
-
return
|
2616
|
+
return Pos(lastWord.line, lastWord.from);
|
2629
2617
|
}
|
2630
2618
|
}
|
2631
2619
|
|
@@ -2641,14 +2629,14 @@
|
|
2641
2629
|
}
|
2642
2630
|
start = idx;
|
2643
2631
|
}
|
2644
|
-
return
|
2632
|
+
return Pos(cm.getCursor().line, idx);
|
2645
2633
|
}
|
2646
2634
|
|
2647
2635
|
function moveToColumn(cm, repeat) {
|
2648
2636
|
// repeat is always >= 1, so repeat - 1 always corresponds
|
2649
2637
|
// to the column we want to go to.
|
2650
2638
|
var line = cm.getCursor().line;
|
2651
|
-
return clipCursorToContent(cm,
|
2639
|
+
return clipCursorToContent(cm, Pos(line, repeat - 1));
|
2652
2640
|
}
|
2653
2641
|
|
2654
2642
|
function updateMark(cm, vim, markName, pos) {
|
@@ -2691,7 +2679,7 @@
|
|
2691
2679
|
var ch = cur.ch;
|
2692
2680
|
symb = symb ? symb : cm.getLine(line).charAt(ch);
|
2693
2681
|
|
2694
|
-
var symbContext = cm.getTokenAt(
|
2682
|
+
var symbContext = cm.getTokenAt(Pos(line, ch + 1)).type;
|
2695
2683
|
var symbCtxLevel = getContextLevel(symbContext);
|
2696
2684
|
|
2697
2685
|
var reverseSymb = ({
|
@@ -2727,7 +2715,7 @@
|
|
2727
2715
|
}
|
2728
2716
|
nextCh = lineText.charAt(index);
|
2729
2717
|
}
|
2730
|
-
var revSymbContext = cm.getTokenAt(
|
2718
|
+
var revSymbContext = cm.getTokenAt(Pos(line, index + 1)).type;
|
2731
2719
|
var revSymbCtxLevel = getContextLevel(revSymbContext);
|
2732
2720
|
if (symbCtxLevel >= revSymbCtxLevel) {
|
2733
2721
|
if (nextCh === symb) {
|
@@ -2739,7 +2727,7 @@
|
|
2739
2727
|
}
|
2740
2728
|
|
2741
2729
|
if (nextCh) {
|
2742
|
-
return
|
2730
|
+
return Pos(line, index);
|
2743
2731
|
}
|
2744
2732
|
return cur;
|
2745
2733
|
}
|
@@ -2747,7 +2735,7 @@
|
|
2747
2735
|
// TODO: perhaps this finagling of start and end positions belonds
|
2748
2736
|
// in codmirror/replaceRange?
|
2749
2737
|
function selectCompanionObject(cm, revSymb, inclusive) {
|
2750
|
-
var cur = cm.getCursor();
|
2738
|
+
var cur = copyCursor(cm.getCursor());
|
2751
2739
|
var end = findMatchedSymbol(cm, cur, revSymb);
|
2752
2740
|
var start = findMatchedSymbol(cm, end);
|
2753
2741
|
|
@@ -2771,7 +2759,7 @@
|
|
2771
2759
|
// have identical opening and closing symbols
|
2772
2760
|
// TODO support across multiple lines
|
2773
2761
|
function findBeginningAndEnd(cm, symb, inclusive) {
|
2774
|
-
var cur = cm.getCursor();
|
2762
|
+
var cur = copyCursor(cm.getCursor());
|
2775
2763
|
var line = cm.getLine(cur.line);
|
2776
2764
|
var chars = line.split('');
|
2777
2765
|
var start, end, i, len;
|
@@ -2823,8 +2811,8 @@
|
|
2823
2811
|
}
|
2824
2812
|
|
2825
2813
|
return {
|
2826
|
-
start:
|
2827
|
-
end:
|
2814
|
+
start: Pos(cur.line, start),
|
2815
|
+
end: Pos(cur.line, end)
|
2828
2816
|
};
|
2829
2817
|
}
|
2830
2818
|
|
@@ -3134,7 +3122,7 @@
|
|
3134
3122
|
// SearchCursor may have returned null because it hit EOF, wrap
|
3135
3123
|
// around and try again.
|
3136
3124
|
cursor = cm.getSearchCursor(query,
|
3137
|
-
(prev) ?
|
3125
|
+
(prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) );
|
3138
3126
|
if (!cursor.find(prev)) {
|
3139
3127
|
return;
|
3140
3128
|
}
|
@@ -3200,7 +3188,7 @@
|
|
3200
3188
|
{ name: 'substitute', shortName: 's' },
|
3201
3189
|
{ name: 'nohlsearch', shortName: 'noh' },
|
3202
3190
|
{ name: 'delmarks', shortName: 'delm' },
|
3203
|
-
{ name: 'registers', shortName: 'reg'
|
3191
|
+
{ name: 'registers', shortName: 'reg' }
|
3204
3192
|
];
|
3205
3193
|
Vim.ExCommandDispatcher = function() {
|
3206
3194
|
this.buildCommandMap_();
|
@@ -3208,14 +3196,10 @@
|
|
3208
3196
|
Vim.ExCommandDispatcher.prototype = {
|
3209
3197
|
processCommand: function(cm, input) {
|
3210
3198
|
var vim = cm.state.vim;
|
3211
|
-
var commandHistoryRegister = vimGlobalState.registerController.getRegister(':');
|
3212
|
-
var previousCommand = commandHistoryRegister.toString();
|
3213
3199
|
if (vim.visualMode) {
|
3214
3200
|
exitVisualMode(cm);
|
3215
3201
|
}
|
3216
3202
|
var inputStream = new CodeMirror.StringStream(input);
|
3217
|
-
// update ": with the latest command whether valid or invalid
|
3218
|
-
commandHistoryRegister.setText(input);
|
3219
3203
|
var params = {};
|
3220
3204
|
params.input = input;
|
3221
3205
|
try {
|
@@ -3234,9 +3218,6 @@
|
|
3234
3218
|
var command = this.matchCommand_(params.commandName);
|
3235
3219
|
if (command) {
|
3236
3220
|
commandName = command.name;
|
3237
|
-
if (command.excludeFromCommandHistory) {
|
3238
|
-
commandHistoryRegister.setText(previousCommand);
|
3239
|
-
}
|
3240
3221
|
this.parseCommandArgs_(inputStream, params, command);
|
3241
3222
|
if (command.type == 'exToKey') {
|
3242
3223
|
// Handle Ex to Key mapping.
|
@@ -3528,7 +3509,7 @@
|
|
3528
3509
|
continue;
|
3529
3510
|
}
|
3530
3511
|
var register = registers[registerName] || new Register();
|
3531
|
-
regInfo += '"' + registerName + ' ' + register.
|
3512
|
+
regInfo += '"' + registerName + ' ' + register.text + '<br>';
|
3532
3513
|
}
|
3533
3514
|
}
|
3534
3515
|
showConfirm(cm, regInfo);
|
@@ -3563,8 +3544,8 @@
|
|
3563
3544
|
var lineStart = params.line || cm.firstLine();
|
3564
3545
|
var lineEnd = params.lineEnd || params.line || cm.lastLine();
|
3565
3546
|
if (lineStart == lineEnd) { return; }
|
3566
|
-
var curStart =
|
3567
|
-
var curEnd =
|
3547
|
+
var curStart = Pos(lineStart, 0);
|
3548
|
+
var curEnd = Pos(lineEnd, lineLength(cm, lineEnd));
|
3568
3549
|
var text = cm.getRange(curStart, curEnd).split('\n');
|
3569
3550
|
var numberRegex = (number == 'decimal') ? /(-?)([\d]+)/ :
|
3570
3551
|
(number == 'hex') ? /(-?)(?:0x)?([0-9a-f]+)/i :
|
@@ -3614,41 +3595,38 @@
|
|
3614
3595
|
'any other getSearchCursor implementation.');
|
3615
3596
|
}
|
3616
3597
|
var argString = params.argString;
|
3617
|
-
var slashes =
|
3598
|
+
var slashes = findUnescapedSlashes(argString);
|
3599
|
+
if (slashes[0] !== 0) {
|
3600
|
+
showConfirm(cm, 'Substitutions should be of the form ' +
|
3601
|
+
':s/pattern/replace/');
|
3602
|
+
return;
|
3603
|
+
}
|
3604
|
+
var regexPart = argString.substring(slashes[0] + 1, slashes[1]);
|
3618
3605
|
var replacePart = '';
|
3619
|
-
|
3620
|
-
|
3621
|
-
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
var confirm = false; // Whether to confirm each replace.
|
3629
|
-
if (slashes[1]) {
|
3630
|
-
replacePart = argString.substring(slashes[1] + 1, slashes[2]);
|
3631
|
-
if (getOption('pcre')) {
|
3632
|
-
replacePart = unescapeRegexReplace(replacePart);
|
3633
|
-
} else {
|
3634
|
-
replacePart = translateRegexReplace(replacePart);
|
3635
|
-
}
|
3636
|
-
vimGlobalState.lastSubstituteReplacePart = replacePart;
|
3637
|
-
}
|
3638
|
-
if (slashes[2]) {
|
3639
|
-
// After the 3rd slash, we can have flags followed by a space followed
|
3640
|
-
// by count.
|
3641
|
-
var trailing = argString.substring(slashes[2] + 1).split(' ');
|
3642
|
-
flagsPart = trailing[0];
|
3643
|
-
count = parseInt(trailing[1]);
|
3606
|
+
var flagsPart;
|
3607
|
+
var count;
|
3608
|
+
var confirm = false; // Whether to confirm each replace.
|
3609
|
+
if (slashes[1]) {
|
3610
|
+
replacePart = argString.substring(slashes[1] + 1, slashes[2]);
|
3611
|
+
if (getOption('pcre')) {
|
3612
|
+
replacePart = unescapeRegexReplace(replacePart);
|
3613
|
+
} else {
|
3614
|
+
replacePart = translateRegexReplace(replacePart);
|
3644
3615
|
}
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3616
|
+
}
|
3617
|
+
if (slashes[2]) {
|
3618
|
+
// After the 3rd slash, we can have flags followed by a space followed
|
3619
|
+
// by count.
|
3620
|
+
var trailing = argString.substring(slashes[2] + 1).split(' ');
|
3621
|
+
flagsPart = trailing[0];
|
3622
|
+
count = parseInt(trailing[1]);
|
3623
|
+
}
|
3624
|
+
if (flagsPart) {
|
3625
|
+
if (flagsPart.indexOf('c') != -1) {
|
3626
|
+
confirm = true;
|
3627
|
+
flagsPart.replace('c', '');
|
3651
3628
|
}
|
3629
|
+
regexPart = regexPart + '/' + flagsPart;
|
3652
3630
|
}
|
3653
3631
|
if (regexPart) {
|
3654
3632
|
// If regex part is empty, then use the previous query. Otherwise use
|
@@ -3661,11 +3639,6 @@
|
|
3661
3639
|
return;
|
3662
3640
|
}
|
3663
3641
|
}
|
3664
|
-
replacePart = replacePart || vimGlobalState.lastSubstituteReplacePart;
|
3665
|
-
if (replacePart === undefined) {
|
3666
|
-
showConfirm(cm, 'No previous substitute regular expression');
|
3667
|
-
return;
|
3668
|
-
}
|
3669
3642
|
var state = getSearchState(cm);
|
3670
3643
|
var query = state.getQuery();
|
3671
3644
|
var lineStart = (params.line !== undefined) ? params.line : cm.getCursor().line;
|
@@ -3674,7 +3647,7 @@
|
|
3674
3647
|
lineStart = lineEnd;
|
3675
3648
|
lineEnd = lineStart + count - 1;
|
3676
3649
|
}
|
3677
|
-
var startPos = clipCursorToContent(cm,
|
3650
|
+
var startPos = clipCursorToContent(cm, Pos(lineStart, 0));
|
3678
3651
|
var cursor = cm.getSearchCursor(query, startPos);
|
3679
3652
|
doReplace(cm, confirm, lineStart, lineEnd, cursor, query, replacePart);
|
3680
3653
|
},
|
@@ -3911,7 +3884,6 @@
|
|
3911
3884
|
function exitInsertMode(cm) {
|
3912
3885
|
var vim = cm.state.vim;
|
3913
3886
|
var macroModeState = vimGlobalState.macroModeState;
|
3914
|
-
var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.');
|
3915
3887
|
var isPlaying = macroModeState.isPlaying;
|
3916
3888
|
if (!isPlaying) {
|
3917
3889
|
cm.off('change', onChange);
|
@@ -3925,13 +3897,11 @@
|
|
3925
3897
|
vim.lastEditInputState.repeatOverride = vim.insertModeRepeat;
|
3926
3898
|
}
|
3927
3899
|
delete vim.insertModeRepeat;
|
3928
|
-
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1
|
3900
|
+
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);
|
3929
3901
|
vim.insertMode = false;
|
3930
3902
|
cm.setOption('keyMap', 'vim');
|
3931
3903
|
cm.setOption('disableInput', true);
|
3932
3904
|
cm.toggleOverwrite(false); // exit replace mode if we were in it.
|
3933
|
-
// update the ". register before exiting insert mode
|
3934
|
-
insertModeChangeRegister.setText(macroModeState.lastInsertModeChanges.changes.join(''));
|
3935
3905
|
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
|
3936
3906
|
if (macroModeState.isRecording) {
|
3937
3907
|
logInsertModeChange(macroModeState);
|
@@ -3964,7 +3934,6 @@
|
|
3964
3934
|
var keyBuffer = register.keyBuffer;
|
3965
3935
|
var imc = 0;
|
3966
3936
|
macroModeState.isPlaying = true;
|
3967
|
-
macroModeState.replaySearchQueries = register.searchQueries.slice(0);
|
3968
3937
|
for (var i = 0; i < keyBuffer.length; i++) {
|
3969
3938
|
var text = keyBuffer[i];
|
3970
3939
|
var match, key;
|
@@ -4003,15 +3972,6 @@
|
|
4003
3972
|
}
|
4004
3973
|
}
|
4005
3974
|
|
4006
|
-
function logSearchQuery(macroModeState, query) {
|
4007
|
-
if (macroModeState.isPlaying) { return; }
|
4008
|
-
var registerName = macroModeState.latestRegister;
|
4009
|
-
var register = vimGlobalState.registerController.getRegister(registerName);
|
4010
|
-
if (register) {
|
4011
|
-
register.pushSearchQuery(query);
|
4012
|
-
}
|
4013
|
-
}
|
4014
|
-
|
4015
3975
|
/**
|
4016
3976
|
* Listens for changes made in insert mode.
|
4017
3977
|
* Should only be active in insert mode.
|
@@ -4160,5 +4120,4 @@
|
|
4160
4120
|
};
|
4161
4121
|
// Initialize Vim and make it available as an API.
|
4162
4122
|
CodeMirror.Vim = Vim();
|
4163
|
-
}
|
4164
|
-
)();
|
4123
|
+
});
|