ace-rails-ap 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ace/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/ace/ace.js +403 -326
  4. data/vendor/assets/javascripts/ace/ext-language_tools.js +56 -40
  5. data/vendor/assets/javascripts/ace/ext-modelist.js +7 -3
  6. data/vendor/assets/javascripts/ace/ext-settings_menu.js +8 -4
  7. data/vendor/assets/javascripts/ace/ext-static_highlight.js +12 -5
  8. data/vendor/assets/javascripts/ace/keybinding-vim.js +5234 -1558
  9. data/vendor/assets/javascripts/ace/mode-abap.js +1 -1
  10. data/vendor/assets/javascripts/ace/mode-abc.js +261 -0
  11. data/vendor/assets/javascripts/ace/mode-actionscript.js +47 -1
  12. data/vendor/assets/javascripts/ace/mode-apache_conf.js +47 -1
  13. data/vendor/assets/javascripts/ace/mode-applescript.js +47 -1
  14. data/vendor/assets/javascripts/ace/mode-autohotkey.js +47 -1
  15. data/vendor/assets/javascripts/ace/mode-batchfile.js +47 -1
  16. data/vendor/assets/javascripts/ace/mode-c_cpp.js +101 -56
  17. data/vendor/assets/javascripts/ace/mode-coffee.js +3 -3
  18. data/vendor/assets/javascripts/ace/mode-coldfusion.js +114 -63
  19. data/vendor/assets/javascripts/ace/mode-csharp.js +99 -55
  20. data/vendor/assets/javascripts/ace/mode-css.js +98 -53
  21. data/vendor/assets/javascripts/ace/mode-curly.js +114 -63
  22. data/vendor/assets/javascripts/ace/mode-d.js +47 -1
  23. data/vendor/assets/javascripts/ace/mode-dart.js +103 -58
  24. data/vendor/assets/javascripts/ace/mode-diff.js +85 -85
  25. data/vendor/assets/javascripts/ace/mode-django.js +114 -63
  26. data/vendor/assets/javascripts/ace/mode-dockerfile.js +97 -52
  27. data/vendor/assets/javascripts/ace/mode-dot.js +47 -1
  28. data/vendor/assets/javascripts/ace/mode-eiffel.js +30 -37
  29. data/vendor/assets/javascripts/ace/mode-ejs.js +117 -63
  30. data/vendor/assets/javascripts/ace/mode-elm.js +47 -1
  31. data/vendor/assets/javascripts/ace/mode-erlang.js +47 -1
  32. data/vendor/assets/javascripts/ace/mode-forth.js +47 -1
  33. data/vendor/assets/javascripts/ace/mode-ftl.js +10 -7
  34. data/vendor/assets/javascripts/ace/mode-glsl.js +101 -56
  35. data/vendor/assets/javascripts/ace/mode-golang.js +96 -51
  36. data/vendor/assets/javascripts/ace/mode-groovy.js +98 -53
  37. data/vendor/assets/javascripts/ace/mode-haml.js +3 -0
  38. data/vendor/assets/javascripts/ace/mode-handlebars.js +114 -63
  39. data/vendor/assets/javascripts/ace/mode-haskell.js +49 -3
  40. data/vendor/assets/javascripts/ace/mode-haxe.js +96 -51
  41. data/vendor/assets/javascripts/ace/mode-html.js +114 -63
  42. data/vendor/assets/javascripts/ace/mode-html_ruby.js +117 -63
  43. data/vendor/assets/javascripts/ace/mode-io.js +47 -1
  44. data/vendor/assets/javascripts/ace/mode-jack.js +96 -51
  45. data/vendor/assets/javascripts/ace/mode-jade.js +10 -7
  46. data/vendor/assets/javascripts/ace/mode-java.js +98 -53
  47. data/vendor/assets/javascripts/ace/mode-javascript.js +98 -53
  48. data/vendor/assets/javascripts/ace/mode-json.js +99 -54
  49. data/vendor/assets/javascripts/ace/mode-jsoniq.js +98 -51
  50. data/vendor/assets/javascripts/ace/mode-jsp.js +106 -58
  51. data/vendor/assets/javascripts/ace/mode-jsx.js +96 -51
  52. data/vendor/assets/javascripts/ace/mode-julia.js +47 -1
  53. data/vendor/assets/javascripts/ace/mode-latex.js +1 -1
  54. data/vendor/assets/javascripts/ace/mode-lean.js +281 -0
  55. data/vendor/assets/javascripts/ace/mode-less.js +96 -51
  56. data/vendor/assets/javascripts/ace/mode-liquid.js +10 -7
  57. data/vendor/assets/javascripts/ace/mode-live_script.js +481 -0
  58. data/vendor/assets/javascripts/ace/mode-livescript.js +5 -8
  59. data/vendor/assets/javascripts/ace/mode-logiql.js +49 -50
  60. data/vendor/assets/javascripts/ace/mode-lsl.js +96 -51
  61. data/vendor/assets/javascripts/ace/mode-lua.js +3 -3
  62. data/vendor/assets/javascripts/ace/mode-luapage.js +117 -66
  63. data/vendor/assets/javascripts/ace/mode-makefile.js +1 -1
  64. data/vendor/assets/javascripts/ace/mode-markdown.js +134 -67
  65. data/vendor/assets/javascripts/ace/mode-mask.js +1985 -0
  66. data/vendor/assets/javascripts/ace/mode-mel.js +96 -51
  67. data/vendor/assets/javascripts/ace/mode-mips_assembler.js +235 -0
  68. data/vendor/assets/javascripts/ace/mode-mipsassembler.js +196 -0
  69. data/vendor/assets/javascripts/ace/mode-nix.js +101 -56
  70. data/vendor/assets/javascripts/ace/mode-objectivec.js +52 -6
  71. data/vendor/assets/javascripts/ace/mode-perl.js +47 -1
  72. data/vendor/assets/javascripts/ace/mode-pgsql.js +1 -1
  73. data/vendor/assets/javascripts/ace/mode-php.js +139 -85
  74. data/vendor/assets/javascripts/ace/mode-powershell.js +96 -51
  75. data/vendor/assets/javascripts/ace/mode-praat.js +47 -1
  76. data/vendor/assets/javascripts/ace/mode-prolog.js +47 -1
  77. data/vendor/assets/javascripts/ace/mode-protobuf.js +101 -56
  78. data/vendor/assets/javascripts/ace/mode-rdoc.js +1 -1
  79. data/vendor/assets/javascripts/ace/mode-rhtml.js +114 -63
  80. data/vendor/assets/javascripts/ace/mode-ruby.js +52 -50
  81. data/vendor/assets/javascripts/ace/mode-rust.js +57 -18
  82. data/vendor/assets/javascripts/ace/mode-scad.js +96 -51
  83. data/vendor/assets/javascripts/ace/mode-scala.js +98 -53
  84. data/vendor/assets/javascripts/ace/mode-scss.js +96 -51
  85. data/vendor/assets/javascripts/ace/mode-sh.js +97 -52
  86. data/vendor/assets/javascripts/ace/mode-sjs.js +98 -53
  87. data/vendor/assets/javascripts/ace/mode-smarty.js +114 -63
  88. data/vendor/assets/javascripts/ace/mode-soy_template.js +114 -63
  89. data/vendor/assets/javascripts/ace/mode-stylus.js +1 -1
  90. data/vendor/assets/javascripts/ace/mode-svg.js +132 -65
  91. data/vendor/assets/javascripts/ace/mode-tcl.js +47 -1
  92. data/vendor/assets/javascripts/ace/mode-twig.js +114 -63
  93. data/vendor/assets/javascripts/ace/mode-typescript.js +98 -53
  94. data/vendor/assets/javascripts/ace/mode-vala.js +96 -51
  95. data/vendor/assets/javascripts/ace/mode-velocity.js +114 -63
  96. data/vendor/assets/javascripts/ace/mode-vhdl.js +21 -21
  97. data/vendor/assets/javascripts/ace/mode-xml.js +34 -12
  98. data/vendor/assets/javascripts/ace/mode-xquery.js +98 -51
  99. data/vendor/assets/javascripts/ace/snippets/abc.js +38 -0
  100. data/vendor/assets/javascripts/ace/snippets/elixir.js +7 -0
  101. data/vendor/assets/javascripts/ace/snippets/elm.js +7 -0
  102. data/vendor/assets/javascripts/ace/snippets/lean.js +7 -0
  103. data/vendor/assets/javascripts/ace/snippets/live_script.js +7 -0
  104. data/vendor/assets/javascripts/ace/snippets/mask.js +7 -0
  105. data/vendor/assets/javascripts/ace/snippets/mips_assembler.js +7 -0
  106. data/vendor/assets/javascripts/ace/snippets/mipsassembler.js +7 -0
  107. data/vendor/assets/javascripts/ace/snippets/r.js +1 -1
  108. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -1
  109. data/vendor/assets/javascripts/ace/theme-github.js +7 -1
  110. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +3 -0
  111. data/vendor/assets/javascripts/ace/theme-kuroir.js +3 -0
  112. data/vendor/assets/javascripts/ace/worker-coffee.js +6 -7
  113. data/vendor/assets/javascripts/ace/worker-css.js +5 -5
  114. data/vendor/assets/javascripts/ace/worker-html.js +4354 -4354
  115. data/vendor/assets/javascripts/ace/worker-javascript.js +2435 -1397
  116. data/vendor/assets/javascripts/ace/worker-json.js +6 -7
  117. data/vendor/assets/javascripts/ace/worker-lua.js +11 -11
  118. data/vendor/assets/javascripts/ace/worker-php.js +4 -8
  119. data/vendor/assets/javascripts/ace/worker-xml.js +3809 -0
  120. data/vendor/assets/javascripts/ace/worker-xquery.js +38 -47
  121. metadata +18 -9
  122. data/vendor/assets/javascripts/ace/ext-options.js +0 -252
  123. data/vendor/assets/javascripts/ace/mode-html_completions.js +0 -309
  124. data/vendor/assets/javascripts/ace/mode-luahtml.js +0 -2415
  125. data/vendor/assets/javascripts/ace/mode-mushcode_high_rules.js +0 -569
  126. data/vendor/assets/javascripts/ace/mode-tmsnippet.js +0 -200
  127. data/vendor/assets/javascripts/ace/theme-kr.js +0 -105
@@ -214,6 +214,19 @@ var initContext = function(editor) {
214
214
  };
215
215
  };
216
216
 
217
+ var getWrapped = function(selection, selected, opening, closing) {
218
+ var rowDiff = selection.end.row - selection.start.row;
219
+ return {
220
+ text: opening + selected + closing,
221
+ selection: [
222
+ 0,
223
+ selection.start.column + 1,
224
+ rowDiff,
225
+ selection.end.column + (rowDiff ? 0 : 1)
226
+ ]
227
+ };
228
+ };
229
+
217
230
  var CstyleBehaviour = function() {
218
231
  this.add("braces", "insertion", function(state, action, editor, session, text) {
219
232
  var cursor = editor.getCursorPosition();
@@ -223,10 +236,7 @@ var CstyleBehaviour = function() {
223
236
  var selection = editor.getSelectionRange();
224
237
  var selected = session.doc.getTextRange(selection);
225
238
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
226
- return {
227
- text: '{' + selected + '}',
228
- selection: false
229
- };
239
+ return getWrapped(selection, selected, '{', '}');
230
240
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
231
241
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
232
242
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -306,10 +316,7 @@ var CstyleBehaviour = function() {
306
316
  var selection = editor.getSelectionRange();
307
317
  var selected = session.doc.getTextRange(selection);
308
318
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
309
- return {
310
- text: '(' + selected + ')',
311
- selection: false
312
- };
319
+ return getWrapped(selection, selected, '(', ')');
313
320
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
314
321
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
315
322
  return {
@@ -354,10 +361,7 @@ var CstyleBehaviour = function() {
354
361
  var selection = editor.getSelectionRange();
355
362
  var selected = session.doc.getTextRange(selection);
356
363
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
357
- return {
358
- text: '[' + selected + ']',
359
- selection: false
360
- };
364
+ return getWrapped(selection, selected, '[', ']');
361
365
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
362
366
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
363
367
  return {
@@ -403,49 +407,44 @@ var CstyleBehaviour = function() {
403
407
  var selection = editor.getSelectionRange();
404
408
  var selected = session.doc.getTextRange(selection);
405
409
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
406
- return {
407
- text: quote + selected + quote,
408
- selection: false
409
- };
410
- } else {
410
+ return getWrapped(selection, selected, quote, quote);
411
+ } else if (!selected) {
411
412
  var cursor = editor.getCursorPosition();
412
413
  var line = session.doc.getLine(cursor.row);
413
414
  var leftChar = line.substring(cursor.column-1, cursor.column);
414
- if (leftChar == '\\') {
415
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
416
+
417
+ var token = session.getTokenAt(cursor.row, cursor.column);
418
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
419
+ if (leftChar == "\\" && token && /escape/.test(token.type))
415
420
  return null;
421
+
422
+ var stringBefore = token && /string/.test(token.type);
423
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
424
+
425
+ var pair;
426
+ if (rightChar == quote) {
427
+ pair = stringBefore !== stringAfter;
428
+ } else {
429
+ if (stringBefore && !stringAfter)
430
+ return null; // wrap string with different quote
431
+ if (stringBefore && stringAfter)
432
+ return null; // do not pair quotes inside strings
433
+ var wordRe = session.$mode.tokenRe;
434
+ wordRe.lastIndex = 0;
435
+ var isWordBefore = wordRe.test(leftChar);
436
+ wordRe.lastIndex = 0;
437
+ var isWordAfter = wordRe.test(leftChar);
438
+ if (isWordBefore || isWordAfter)
439
+ return null; // before or after alphanumeric
440
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
441
+ return null; // there is rightChar and it isn't closing
442
+ pair = true;
416
443
  }
417
- var tokens = session.getTokens(selection.start.row);
418
- var col = 0, token;
419
- var quotepos = -1; // Track whether we're inside an open quote.
420
-
421
- for (var x = 0; x < tokens.length; x++) {
422
- token = tokens[x];
423
- if (token.type == "string") {
424
- quotepos = -1;
425
- } else if (quotepos < 0) {
426
- quotepos = token.value.indexOf(quote);
427
- }
428
- if ((token.value.length + col) > selection.start.column) {
429
- break;
430
- }
431
- col += tokens[x].value.length;
432
- }
433
- if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
434
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
435
- return;
436
- return {
437
- text: quote + quote,
438
- selection: [1,1]
439
- };
440
- } else if (token && token.type === "string") {
441
- var rightChar = line.substring(cursor.column, cursor.column + 1);
442
- if (rightChar == quote) {
443
- return {
444
- text: '',
445
- selection: [1, 1]
446
- };
447
- }
448
- }
444
+ return {
445
+ text: pair ? quote + quote : "",
446
+ selection: [1,1]
447
+ };
449
448
  }
450
449
  }
451
450
  });
@@ -557,12 +556,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
557
556
  oop.inherits(FoldMode, BaseFoldMode);
558
557
 
559
558
  (function() {
560
-
559
+
561
560
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
562
561
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
562
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
563
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
564
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
565
+ this._getFoldWidgetBase = this.getFoldWidget;
566
+ this.getFoldWidget = function(session, foldStyle, row) {
567
+ var line = session.getLine(row);
568
+
569
+ if (this.singleLineBlockCommentRe.test(line)) {
570
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
571
+ return "";
572
+ }
573
+
574
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
575
+
576
+ if (!fw && this.startRegionRe.test(line))
577
+ return "start"; // lineCommentRegionStart
578
+
579
+ return fw;
580
+ };
563
581
 
564
582
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
565
583
  var line = session.getLine(row);
584
+
585
+ if (this.startRegionRe.test(line))
586
+ return this.getCommentRegionBlock(session, line, row);
587
+
566
588
  var match = line.match(this.foldingStartMarker);
567
589
  if (match) {
568
590
  var i = match.index;
@@ -627,6 +649,29 @@ oop.inherits(FoldMode, BaseFoldMode);
627
649
 
628
650
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
629
651
  };
652
+
653
+ this.getCommentRegionBlock = function(session, line, row) {
654
+ var startColumn = line.search(/\s*$/);
655
+ var maxRow = session.getLength();
656
+ var startRow = row;
657
+
658
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
659
+ var depth = 1;
660
+ while (++row < maxRow) {
661
+ line = session.getLine(row);
662
+ var m = re.exec(line);
663
+ if (!m) continue;
664
+ if (m[1]) depth--;
665
+ else depth++;
666
+
667
+ if (!depth) break;
668
+ }
669
+
670
+ var endRow = row;
671
+ if (endRow > startRow) {
672
+ return new Range(startRow, startColumn, endRow, line.length);
673
+ }
674
+ };
630
675
 
631
676
  }).call(FoldMode.prototype);
632
677
 
@@ -287,12 +287,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
287
287
  oop.inherits(FoldMode, BaseFoldMode);
288
288
 
289
289
  (function() {
290
-
290
+
291
291
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
292
292
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
293
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
294
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
295
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
296
+ this._getFoldWidgetBase = this.getFoldWidget;
297
+ this.getFoldWidget = function(session, foldStyle, row) {
298
+ var line = session.getLine(row);
299
+
300
+ if (this.singleLineBlockCommentRe.test(line)) {
301
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
302
+ return "";
303
+ }
304
+
305
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
306
+
307
+ if (!fw && this.startRegionRe.test(line))
308
+ return "start"; // lineCommentRegionStart
309
+
310
+ return fw;
311
+ };
293
312
 
294
313
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
295
314
  var line = session.getLine(row);
315
+
316
+ if (this.startRegionRe.test(line))
317
+ return this.getCommentRegionBlock(session, line, row);
318
+
296
319
  var match = line.match(this.foldingStartMarker);
297
320
  if (match) {
298
321
  var i = match.index;
@@ -357,6 +380,29 @@ oop.inherits(FoldMode, BaseFoldMode);
357
380
 
358
381
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
359
382
  };
383
+
384
+ this.getCommentRegionBlock = function(session, line, row) {
385
+ var startColumn = line.search(/\s*$/);
386
+ var maxRow = session.getLength();
387
+ var startRow = row;
388
+
389
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
390
+ var depth = 1;
391
+ while (++row < maxRow) {
392
+ line = session.getLine(row);
393
+ var m = re.exec(line);
394
+ if (!m) continue;
395
+ if (m[1]) depth--;
396
+ else depth++;
397
+
398
+ if (!depth) break;
399
+ }
400
+
401
+ var endRow = row;
402
+ if (endRow > startRow) {
403
+ return new Range(startRow, startColumn, endRow, line.length);
404
+ }
405
+ };
360
406
 
361
407
  }).call(FoldMode.prototype);
362
408
 
@@ -219,12 +219,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
219
219
  oop.inherits(FoldMode, BaseFoldMode);
220
220
 
221
221
  (function() {
222
-
222
+
223
223
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
224
224
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
225
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
226
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
227
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
228
+ this._getFoldWidgetBase = this.getFoldWidget;
229
+ this.getFoldWidget = function(session, foldStyle, row) {
230
+ var line = session.getLine(row);
231
+
232
+ if (this.singleLineBlockCommentRe.test(line)) {
233
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
234
+ return "";
235
+ }
236
+
237
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
238
+
239
+ if (!fw && this.startRegionRe.test(line))
240
+ return "start"; // lineCommentRegionStart
241
+
242
+ return fw;
243
+ };
225
244
 
226
245
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
227
246
  var line = session.getLine(row);
247
+
248
+ if (this.startRegionRe.test(line))
249
+ return this.getCommentRegionBlock(session, line, row);
250
+
228
251
  var match = line.match(this.foldingStartMarker);
229
252
  if (match) {
230
253
  var i = match.index;
@@ -289,6 +312,29 @@ oop.inherits(FoldMode, BaseFoldMode);
289
312
 
290
313
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
291
314
  };
315
+
316
+ this.getCommentRegionBlock = function(session, line, row) {
317
+ var startColumn = line.search(/\s*$/);
318
+ var maxRow = session.getLength();
319
+ var startRow = row;
320
+
321
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
322
+ var depth = 1;
323
+ while (++row < maxRow) {
324
+ line = session.getLine(row);
325
+ var m = re.exec(line);
326
+ if (!m) continue;
327
+ if (m[1]) depth--;
328
+ else depth++;
329
+
330
+ if (!depth) break;
331
+ }
332
+
333
+ var endRow = row;
334
+ if (endRow > startRow) {
335
+ return new Range(startRow, startColumn, endRow, line.length);
336
+ }
337
+ };
292
338
 
293
339
  }).call(FoldMode.prototype);
294
340
 
@@ -66,13 +66,13 @@ var c_cppHighlightRules = function() {
66
66
  var storageType = (
67
67
  "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
68
68
  "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
69
- "class|wchar_t|template"
69
+ "class|wchar_t|template|char16_t|char32_t"
70
70
  );
71
71
 
72
72
  var storageModifiers = (
73
73
  "const|extern|register|restrict|static|volatile|inline|private|" +
74
74
  "protected|public|friend|explicit|virtual|export|mutable|typename|" +
75
- "constexpr|new|delete"
75
+ "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
76
76
  );
77
77
 
78
78
  var keywordOperators = (
@@ -81,7 +81,7 @@ var c_cppHighlightRules = function() {
81
81
  );
82
82
 
83
83
  var builtinConstants = (
84
- "NULL|true|false|TRUE|FALSE"
84
+ "NULL|true|false|TRUE|FALSE|nullptr"
85
85
  );
86
86
 
87
87
  var keywordMapper = this.$keywords = this.createKeywordMapper({
@@ -129,11 +129,11 @@ var c_cppHighlightRules = function() {
129
129
  regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
130
130
  }, {
131
131
  token : "keyword", // pre-compiler directives
132
- regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b",
132
+ regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
133
133
  next : "directive"
134
134
  }, {
135
135
  token : "keyword", // special case pre-compiler directive
136
- regex : "(?:#\\s*endif)\\b"
136
+ regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
137
137
  }, {
138
138
  token : "support.function.C99.c",
139
139
  regex : cFunctions
@@ -314,6 +314,19 @@ var initContext = function(editor) {
314
314
  };
315
315
  };
316
316
 
317
+ var getWrapped = function(selection, selected, opening, closing) {
318
+ var rowDiff = selection.end.row - selection.start.row;
319
+ return {
320
+ text: opening + selected + closing,
321
+ selection: [
322
+ 0,
323
+ selection.start.column + 1,
324
+ rowDiff,
325
+ selection.end.column + (rowDiff ? 0 : 1)
326
+ ]
327
+ };
328
+ };
329
+
317
330
  var CstyleBehaviour = function() {
318
331
  this.add("braces", "insertion", function(state, action, editor, session, text) {
319
332
  var cursor = editor.getCursorPosition();
@@ -323,10 +336,7 @@ var CstyleBehaviour = function() {
323
336
  var selection = editor.getSelectionRange();
324
337
  var selected = session.doc.getTextRange(selection);
325
338
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
326
- return {
327
- text: '{' + selected + '}',
328
- selection: false
329
- };
339
+ return getWrapped(selection, selected, '{', '}');
330
340
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
331
341
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
332
342
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -406,10 +416,7 @@ var CstyleBehaviour = function() {
406
416
  var selection = editor.getSelectionRange();
407
417
  var selected = session.doc.getTextRange(selection);
408
418
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
409
- return {
410
- text: '(' + selected + ')',
411
- selection: false
412
- };
419
+ return getWrapped(selection, selected, '(', ')');
413
420
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
414
421
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
415
422
  return {
@@ -454,10 +461,7 @@ var CstyleBehaviour = function() {
454
461
  var selection = editor.getSelectionRange();
455
462
  var selected = session.doc.getTextRange(selection);
456
463
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
457
- return {
458
- text: '[' + selected + ']',
459
- selection: false
460
- };
464
+ return getWrapped(selection, selected, '[', ']');
461
465
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
462
466
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
463
467
  return {
@@ -503,49 +507,44 @@ var CstyleBehaviour = function() {
503
507
  var selection = editor.getSelectionRange();
504
508
  var selected = session.doc.getTextRange(selection);
505
509
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
506
- return {
507
- text: quote + selected + quote,
508
- selection: false
509
- };
510
- } else {
510
+ return getWrapped(selection, selected, quote, quote);
511
+ } else if (!selected) {
511
512
  var cursor = editor.getCursorPosition();
512
513
  var line = session.doc.getLine(cursor.row);
513
514
  var leftChar = line.substring(cursor.column-1, cursor.column);
514
- if (leftChar == '\\') {
515
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
516
+
517
+ var token = session.getTokenAt(cursor.row, cursor.column);
518
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
519
+ if (leftChar == "\\" && token && /escape/.test(token.type))
515
520
  return null;
521
+
522
+ var stringBefore = token && /string/.test(token.type);
523
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
524
+
525
+ var pair;
526
+ if (rightChar == quote) {
527
+ pair = stringBefore !== stringAfter;
528
+ } else {
529
+ if (stringBefore && !stringAfter)
530
+ return null; // wrap string with different quote
531
+ if (stringBefore && stringAfter)
532
+ return null; // do not pair quotes inside strings
533
+ var wordRe = session.$mode.tokenRe;
534
+ wordRe.lastIndex = 0;
535
+ var isWordBefore = wordRe.test(leftChar);
536
+ wordRe.lastIndex = 0;
537
+ var isWordAfter = wordRe.test(leftChar);
538
+ if (isWordBefore || isWordAfter)
539
+ return null; // before or after alphanumeric
540
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
541
+ return null; // there is rightChar and it isn't closing
542
+ pair = true;
516
543
  }
517
- var tokens = session.getTokens(selection.start.row);
518
- var col = 0, token;
519
- var quotepos = -1; // Track whether we're inside an open quote.
520
-
521
- for (var x = 0; x < tokens.length; x++) {
522
- token = tokens[x];
523
- if (token.type == "string") {
524
- quotepos = -1;
525
- } else if (quotepos < 0) {
526
- quotepos = token.value.indexOf(quote);
527
- }
528
- if ((token.value.length + col) > selection.start.column) {
529
- break;
530
- }
531
- col += tokens[x].value.length;
532
- }
533
- if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
534
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
535
- return;
536
- return {
537
- text: quote + quote,
538
- selection: [1,1]
539
- };
540
- } else if (token && token.type === "string") {
541
- var rightChar = line.substring(cursor.column, cursor.column + 1);
542
- if (rightChar == quote) {
543
- return {
544
- text: '',
545
- selection: [1, 1]
546
- };
547
- }
548
- }
544
+ return {
545
+ text: pair ? quote + quote : "",
546
+ selection: [1,1]
547
+ };
549
548
  }
550
549
  }
551
550
  });
@@ -657,12 +656,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
657
656
  oop.inherits(FoldMode, BaseFoldMode);
658
657
 
659
658
  (function() {
660
-
659
+
661
660
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
662
661
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
662
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
663
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
664
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
665
+ this._getFoldWidgetBase = this.getFoldWidget;
666
+ this.getFoldWidget = function(session, foldStyle, row) {
667
+ var line = session.getLine(row);
668
+
669
+ if (this.singleLineBlockCommentRe.test(line)) {
670
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
671
+ return "";
672
+ }
673
+
674
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
675
+
676
+ if (!fw && this.startRegionRe.test(line))
677
+ return "start"; // lineCommentRegionStart
678
+
679
+ return fw;
680
+ };
663
681
 
664
682
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
665
683
  var line = session.getLine(row);
684
+
685
+ if (this.startRegionRe.test(line))
686
+ return this.getCommentRegionBlock(session, line, row);
687
+
666
688
  var match = line.match(this.foldingStartMarker);
667
689
  if (match) {
668
690
  var i = match.index;
@@ -727,6 +749,29 @@ oop.inherits(FoldMode, BaseFoldMode);
727
749
 
728
750
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
729
751
  };
752
+
753
+ this.getCommentRegionBlock = function(session, line, row) {
754
+ var startColumn = line.search(/\s*$/);
755
+ var maxRow = session.getLength();
756
+ var startRow = row;
757
+
758
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
759
+ var depth = 1;
760
+ while (++row < maxRow) {
761
+ line = session.getLine(row);
762
+ var m = re.exec(line);
763
+ if (!m) continue;
764
+ if (m[1]) depth--;
765
+ else depth++;
766
+
767
+ if (!depth) break;
768
+ }
769
+
770
+ var endRow = row;
771
+ if (endRow > startRow) {
772
+ return new Range(startRow, startColumn, endRow, line.length);
773
+ }
774
+ };
730
775
 
731
776
  }).call(FoldMode.prototype);
732
777