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
@@ -8,7 +8,7 @@ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|al
8
8
  var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
9
9
  var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
10
10
  var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
11
- var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
11
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
12
12
 
13
13
  var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
14
14
  var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
@@ -5,6 +5,9 @@ var oop = require("../lib/oop");
5
5
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6
6
 
7
7
  var XmlHighlightRules = function(normalize) {
8
+
9
+ var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
10
+
8
11
  this.$rules = {
9
12
  start : [
10
13
  {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
@@ -14,7 +17,7 @@ var XmlHighlightRules = function(normalize) {
14
17
  },
15
18
  {
16
19
  token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
17
- regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
20
+ regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
18
21
  },
19
22
  {token : "comment.xml", regex : "<\\!--", next : "comment"},
20
23
  {
@@ -30,7 +33,7 @@ var XmlHighlightRules = function(normalize) {
30
33
 
31
34
  xml_decl : [{
32
35
  token : "entity.other.attribute-name.decl-attribute-name.xml",
33
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
36
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
34
37
  }, {
35
38
  token : "keyword.operator.decl-attribute-equals.xml",
36
39
  regex : "="
@@ -66,7 +69,7 @@ var XmlHighlightRules = function(normalize) {
66
69
  next: "pop"
67
70
  }, {
68
71
  token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
69
- regex : "(<\\!)([-_a-zA-Z0-9]+)",
72
+ regex : "(<\\!)(" + tagRegex + ")",
70
73
  push : [{
71
74
  token : "text",
72
75
  regex : "\\s+"
@@ -102,7 +105,7 @@ var XmlHighlightRules = function(normalize) {
102
105
 
103
106
  tag : [{
104
107
  token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
105
- regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
108
+ regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
106
109
  next: [
107
110
  {include : "attributes"},
108
111
  {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
@@ -133,7 +136,7 @@ var XmlHighlightRules = function(normalize) {
133
136
 
134
137
  attributes: [{
135
138
  token : "entity.other.attribute-name.xml",
136
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
139
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
137
140
  }, {
138
141
  token : "keyword.operator.attribute-equals.xml",
139
142
  regex : "="
@@ -326,6 +329,8 @@ var XmlBehaviour = function () {
326
329
  var token = iterator.getCurrentToken();
327
330
 
328
331
  if (token && token.type.indexOf("tag-close") !== -1) {
332
+ if (token.value == "/>")
333
+ return;
329
334
  while (token && token.type.indexOf("tag-name") === -1) {
330
335
  token = iterator.stepBackward();
331
336
  }
@@ -525,9 +530,6 @@ function is(token, type) {
525
530
  if (!tag || top.tagName == tag.tagName) {
526
531
  return stack.pop();
527
532
  }
528
- else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
529
- return;
530
- }
531
533
  else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
532
534
  stack.pop();
533
535
  continue;
@@ -553,6 +555,8 @@ function is(token, type) {
553
555
  row: row,
554
556
  column: firstTag.start.column + firstTag.tagName.length + 2
555
557
  };
558
+ if (firstTag.start.row == firstTag.end.row)
559
+ start.column = firstTag.end.column;
556
560
  while (tag = this._readTagForward(iterator)) {
557
561
  if (tag.selfClosing) {
558
562
  if (!stack.length) {
@@ -594,6 +598,8 @@ function is(token, type) {
594
598
  this._pop(stack, tag);
595
599
  if (stack.length == 0) {
596
600
  tag.start.column += tag.tagName.length + 2;
601
+ if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
602
+ tag.start.column = tag.end.column;
597
603
  return Range.fromPoints(tag.start, end);
598
604
  }
599
605
  }
@@ -609,7 +615,7 @@ function is(token, type) {
609
615
 
610
616
  });
611
617
 
612
- define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml"], function(require, exports, module) {
618
+ define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml","ace/worker/worker_client"], function(require, exports, module) {
613
619
  "use strict";
614
620
 
615
621
  var oop = require("../lib/oop");
@@ -618,11 +624,12 @@ var TextMode = require("./text").Mode;
618
624
  var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
619
625
  var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
620
626
  var XmlFoldMode = require("./folding/xml").FoldMode;
627
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
621
628
 
622
629
  var Mode = function() {
623
- this.HighlightRules = XmlHighlightRules;
624
- this.$behaviour = new XmlBehaviour();
625
- this.foldingRules = new XmlFoldMode();
630
+ this.HighlightRules = XmlHighlightRules;
631
+ this.$behaviour = new XmlBehaviour();
632
+ this.foldingRules = new XmlFoldMode();
626
633
  };
627
634
 
628
635
  oop.inherits(Mode, TextMode);
@@ -633,6 +640,21 @@ oop.inherits(Mode, TextMode);
633
640
 
634
641
  this.blockComment = {start: "<!--", end: "-->"};
635
642
 
643
+ this.createWorker = function(session) {
644
+ var worker = new WorkerClient(["ace"], "ace/mode/xml_worker", "Worker");
645
+ worker.attachToDocument(session.getDocument());
646
+
647
+ worker.on("error", function(e) {
648
+ session.setAnnotations(e.data);
649
+ });
650
+
651
+ worker.on("terminate", function() {
652
+ session.clearAnnotations();
653
+ });
654
+
655
+ return worker;
656
+ };
657
+
636
658
  this.$id = "ace/mode/xml";
637
659
  }).call(Mode.prototype);
638
660
 
@@ -817,7 +839,7 @@ var JavaScriptHighlightRules = function(options) {
817
839
  regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
818
840
  }, {
819
841
  token : ["punctuation.operator", "support.function.dom"],
820
- regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
842
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
821
843
  }, {
822
844
  token : ["punctuation.operator", "support.constant"],
823
845
  regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
@@ -1116,6 +1138,19 @@ var initContext = function(editor) {
1116
1138
  };
1117
1139
  };
1118
1140
 
1141
+ var getWrapped = function(selection, selected, opening, closing) {
1142
+ var rowDiff = selection.end.row - selection.start.row;
1143
+ return {
1144
+ text: opening + selected + closing,
1145
+ selection: [
1146
+ 0,
1147
+ selection.start.column + 1,
1148
+ rowDiff,
1149
+ selection.end.column + (rowDiff ? 0 : 1)
1150
+ ]
1151
+ };
1152
+ };
1153
+
1119
1154
  var CstyleBehaviour = function() {
1120
1155
  this.add("braces", "insertion", function(state, action, editor, session, text) {
1121
1156
  var cursor = editor.getCursorPosition();
@@ -1125,10 +1160,7 @@ var CstyleBehaviour = function() {
1125
1160
  var selection = editor.getSelectionRange();
1126
1161
  var selected = session.doc.getTextRange(selection);
1127
1162
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
1128
- return {
1129
- text: '{' + selected + '}',
1130
- selection: false
1131
- };
1163
+ return getWrapped(selection, selected, '{', '}');
1132
1164
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1133
1165
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
1134
1166
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -1208,10 +1240,7 @@ var CstyleBehaviour = function() {
1208
1240
  var selection = editor.getSelectionRange();
1209
1241
  var selected = session.doc.getTextRange(selection);
1210
1242
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
1211
- return {
1212
- text: '(' + selected + ')',
1213
- selection: false
1214
- };
1243
+ return getWrapped(selection, selected, '(', ')');
1215
1244
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1216
1245
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
1217
1246
  return {
@@ -1256,10 +1285,7 @@ var CstyleBehaviour = function() {
1256
1285
  var selection = editor.getSelectionRange();
1257
1286
  var selected = session.doc.getTextRange(selection);
1258
1287
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
1259
- return {
1260
- text: '[' + selected + ']',
1261
- selection: false
1262
- };
1288
+ return getWrapped(selection, selected, '[', ']');
1263
1289
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1264
1290
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
1265
1291
  return {
@@ -1305,49 +1331,44 @@ var CstyleBehaviour = function() {
1305
1331
  var selection = editor.getSelectionRange();
1306
1332
  var selected = session.doc.getTextRange(selection);
1307
1333
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
1308
- return {
1309
- text: quote + selected + quote,
1310
- selection: false
1311
- };
1312
- } else {
1334
+ return getWrapped(selection, selected, quote, quote);
1335
+ } else if (!selected) {
1313
1336
  var cursor = editor.getCursorPosition();
1314
1337
  var line = session.doc.getLine(cursor.row);
1315
1338
  var leftChar = line.substring(cursor.column-1, cursor.column);
1316
- if (leftChar == '\\') {
1339
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1340
+
1341
+ var token = session.getTokenAt(cursor.row, cursor.column);
1342
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
1343
+ if (leftChar == "\\" && token && /escape/.test(token.type))
1317
1344
  return null;
1345
+
1346
+ var stringBefore = token && /string/.test(token.type);
1347
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
1348
+
1349
+ var pair;
1350
+ if (rightChar == quote) {
1351
+ pair = stringBefore !== stringAfter;
1352
+ } else {
1353
+ if (stringBefore && !stringAfter)
1354
+ return null; // wrap string with different quote
1355
+ if (stringBefore && stringAfter)
1356
+ return null; // do not pair quotes inside strings
1357
+ var wordRe = session.$mode.tokenRe;
1358
+ wordRe.lastIndex = 0;
1359
+ var isWordBefore = wordRe.test(leftChar);
1360
+ wordRe.lastIndex = 0;
1361
+ var isWordAfter = wordRe.test(leftChar);
1362
+ if (isWordBefore || isWordAfter)
1363
+ return null; // before or after alphanumeric
1364
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
1365
+ return null; // there is rightChar and it isn't closing
1366
+ pair = true;
1318
1367
  }
1319
- var tokens = session.getTokens(selection.start.row);
1320
- var col = 0, token;
1321
- var quotepos = -1; // Track whether we're inside an open quote.
1322
-
1323
- for (var x = 0; x < tokens.length; x++) {
1324
- token = tokens[x];
1325
- if (token.type == "string") {
1326
- quotepos = -1;
1327
- } else if (quotepos < 0) {
1328
- quotepos = token.value.indexOf(quote);
1329
- }
1330
- if ((token.value.length + col) > selection.start.column) {
1331
- break;
1332
- }
1333
- col += tokens[x].value.length;
1334
- }
1335
- 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)))) {
1336
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
1337
- return;
1338
- return {
1339
- text: quote + quote,
1340
- selection: [1,1]
1341
- };
1342
- } else if (token && token.type === "string") {
1343
- var rightChar = line.substring(cursor.column, cursor.column + 1);
1344
- if (rightChar == quote) {
1345
- return {
1346
- text: '',
1347
- selection: [1, 1]
1348
- };
1349
- }
1350
- }
1368
+ return {
1369
+ text: pair ? quote + quote : "",
1370
+ selection: [1,1]
1371
+ };
1351
1372
  }
1352
1373
  }
1353
1374
  });
@@ -1459,12 +1480,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
1459
1480
  oop.inherits(FoldMode, BaseFoldMode);
1460
1481
 
1461
1482
  (function() {
1462
-
1483
+
1463
1484
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
1464
1485
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
1486
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
1487
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
1488
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
1489
+ this._getFoldWidgetBase = this.getFoldWidget;
1490
+ this.getFoldWidget = function(session, foldStyle, row) {
1491
+ var line = session.getLine(row);
1492
+
1493
+ if (this.singleLineBlockCommentRe.test(line)) {
1494
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
1495
+ return "";
1496
+ }
1497
+
1498
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
1499
+
1500
+ if (!fw && this.startRegionRe.test(line))
1501
+ return "start"; // lineCommentRegionStart
1502
+
1503
+ return fw;
1504
+ };
1465
1505
 
1466
1506
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
1467
1507
  var line = session.getLine(row);
1508
+
1509
+ if (this.startRegionRe.test(line))
1510
+ return this.getCommentRegionBlock(session, line, row);
1511
+
1468
1512
  var match = line.match(this.foldingStartMarker);
1469
1513
  if (match) {
1470
1514
  var i = match.index;
@@ -1529,6 +1573,29 @@ oop.inherits(FoldMode, BaseFoldMode);
1529
1573
 
1530
1574
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
1531
1575
  };
1576
+
1577
+ this.getCommentRegionBlock = function(session, line, row) {
1578
+ var startColumn = line.search(/\s*$/);
1579
+ var maxRow = session.getLength();
1580
+ var startRow = row;
1581
+
1582
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
1583
+ var depth = 1;
1584
+ while (++row < maxRow) {
1585
+ line = session.getLine(row);
1586
+ var m = re.exec(line);
1587
+ if (!m) continue;
1588
+ if (m[1]) depth--;
1589
+ else depth++;
1590
+
1591
+ if (!depth) break;
1592
+ }
1593
+
1594
+ var endRow = row;
1595
+ if (endRow > startRow) {
1596
+ return new Range(startRow, startColumn, endRow, line.length);
1597
+ }
1598
+ };
1532
1599
 
1533
1600
  }).call(FoldMode.prototype);
1534
1601
 
@@ -1604,7 +1671,7 @@ oop.inherits(Mode, TextMode);
1604
1671
  var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1605
1672
  worker.attachToDocument(session.getDocument());
1606
1673
 
1607
- worker.on("jslint", function(results) {
1674
+ worker.on("annotate", function(results) {
1608
1675
  session.setAnnotations(results.data);
1609
1676
  });
1610
1677
 
@@ -18,12 +18,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
18
18
  oop.inherits(FoldMode, BaseFoldMode);
19
19
 
20
20
  (function() {
21
-
21
+
22
22
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
23
23
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
24
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
25
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
26
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
27
+ this._getFoldWidgetBase = this.getFoldWidget;
28
+ this.getFoldWidget = function(session, foldStyle, row) {
29
+ var line = session.getLine(row);
30
+
31
+ if (this.singleLineBlockCommentRe.test(line)) {
32
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
33
+ return "";
34
+ }
35
+
36
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
37
+
38
+ if (!fw && this.startRegionRe.test(line))
39
+ return "start"; // lineCommentRegionStart
40
+
41
+ return fw;
42
+ };
24
43
 
25
44
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
26
45
  var line = session.getLine(row);
46
+
47
+ if (this.startRegionRe.test(line))
48
+ return this.getCommentRegionBlock(session, line, row);
49
+
27
50
  var match = line.match(this.foldingStartMarker);
28
51
  if (match) {
29
52
  var i = match.index;
@@ -88,6 +111,29 @@ oop.inherits(FoldMode, BaseFoldMode);
88
111
 
89
112
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
90
113
  };
114
+
115
+ this.getCommentRegionBlock = function(session, line, row) {
116
+ var startColumn = line.search(/\s*$/);
117
+ var maxRow = session.getLength();
118
+ var startRow = row;
119
+
120
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
121
+ var depth = 1;
122
+ while (++row < maxRow) {
123
+ line = session.getLine(row);
124
+ var m = re.exec(line);
125
+ if (!m) continue;
126
+ if (m[1]) depth--;
127
+ else depth++;
128
+
129
+ if (!depth) break;
130
+ }
131
+
132
+ var endRow = row;
133
+ if (endRow > startRow) {
134
+ return new Range(startRow, startColumn, endRow, line.length);
135
+ }
136
+ };
91
137
 
92
138
  }).call(FoldMode.prototype);
93
139
 
@@ -176,7 +176,7 @@ var JavaScriptHighlightRules = function(options) {
176
176
  regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
177
177
  }, {
178
178
  token : ["punctuation.operator", "support.function.dom"],
179
- regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
179
+ regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
180
180
  }, {
181
181
  token : ["punctuation.operator", "support.constant"],
182
182
  regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
@@ -475,6 +475,19 @@ var initContext = function(editor) {
475
475
  };
476
476
  };
477
477
 
478
+ var getWrapped = function(selection, selected, opening, closing) {
479
+ var rowDiff = selection.end.row - selection.start.row;
480
+ return {
481
+ text: opening + selected + closing,
482
+ selection: [
483
+ 0,
484
+ selection.start.column + 1,
485
+ rowDiff,
486
+ selection.end.column + (rowDiff ? 0 : 1)
487
+ ]
488
+ };
489
+ };
490
+
478
491
  var CstyleBehaviour = function() {
479
492
  this.add("braces", "insertion", function(state, action, editor, session, text) {
480
493
  var cursor = editor.getCursorPosition();
@@ -484,10 +497,7 @@ var CstyleBehaviour = function() {
484
497
  var selection = editor.getSelectionRange();
485
498
  var selected = session.doc.getTextRange(selection);
486
499
  if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
487
- return {
488
- text: '{' + selected + '}',
489
- selection: false
490
- };
500
+ return getWrapped(selection, selected, '{', '}');
491
501
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
492
502
  if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
493
503
  CstyleBehaviour.recordAutoInsert(editor, session, "}");
@@ -567,10 +577,7 @@ var CstyleBehaviour = function() {
567
577
  var selection = editor.getSelectionRange();
568
578
  var selected = session.doc.getTextRange(selection);
569
579
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
570
- return {
571
- text: '(' + selected + ')',
572
- selection: false
573
- };
580
+ return getWrapped(selection, selected, '(', ')');
574
581
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
575
582
  CstyleBehaviour.recordAutoInsert(editor, session, ")");
576
583
  return {
@@ -615,10 +622,7 @@ var CstyleBehaviour = function() {
615
622
  var selection = editor.getSelectionRange();
616
623
  var selected = session.doc.getTextRange(selection);
617
624
  if (selected !== "" && editor.getWrapBehavioursEnabled()) {
618
- return {
619
- text: '[' + selected + ']',
620
- selection: false
621
- };
625
+ return getWrapped(selection, selected, '[', ']');
622
626
  } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
623
627
  CstyleBehaviour.recordAutoInsert(editor, session, "]");
624
628
  return {
@@ -664,49 +668,44 @@ var CstyleBehaviour = function() {
664
668
  var selection = editor.getSelectionRange();
665
669
  var selected = session.doc.getTextRange(selection);
666
670
  if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
667
- return {
668
- text: quote + selected + quote,
669
- selection: false
670
- };
671
- } else {
671
+ return getWrapped(selection, selected, quote, quote);
672
+ } else if (!selected) {
672
673
  var cursor = editor.getCursorPosition();
673
674
  var line = session.doc.getLine(cursor.row);
674
675
  var leftChar = line.substring(cursor.column-1, cursor.column);
675
- if (leftChar == '\\') {
676
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
677
+
678
+ var token = session.getTokenAt(cursor.row, cursor.column);
679
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
680
+ if (leftChar == "\\" && token && /escape/.test(token.type))
676
681
  return null;
682
+
683
+ var stringBefore = token && /string/.test(token.type);
684
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
685
+
686
+ var pair;
687
+ if (rightChar == quote) {
688
+ pair = stringBefore !== stringAfter;
689
+ } else {
690
+ if (stringBefore && !stringAfter)
691
+ return null; // wrap string with different quote
692
+ if (stringBefore && stringAfter)
693
+ return null; // do not pair quotes inside strings
694
+ var wordRe = session.$mode.tokenRe;
695
+ wordRe.lastIndex = 0;
696
+ var isWordBefore = wordRe.test(leftChar);
697
+ wordRe.lastIndex = 0;
698
+ var isWordAfter = wordRe.test(leftChar);
699
+ if (isWordBefore || isWordAfter)
700
+ return null; // before or after alphanumeric
701
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
702
+ return null; // there is rightChar and it isn't closing
703
+ pair = true;
677
704
  }
678
- var tokens = session.getTokens(selection.start.row);
679
- var col = 0, token;
680
- var quotepos = -1; // Track whether we're inside an open quote.
681
-
682
- for (var x = 0; x < tokens.length; x++) {
683
- token = tokens[x];
684
- if (token.type == "string") {
685
- quotepos = -1;
686
- } else if (quotepos < 0) {
687
- quotepos = token.value.indexOf(quote);
688
- }
689
- if ((token.value.length + col) > selection.start.column) {
690
- break;
691
- }
692
- col += tokens[x].value.length;
693
- }
694
- 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)))) {
695
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
696
- return;
697
- return {
698
- text: quote + quote,
699
- selection: [1,1]
700
- };
701
- } else if (token && token.type === "string") {
702
- var rightChar = line.substring(cursor.column, cursor.column + 1);
703
- if (rightChar == quote) {
704
- return {
705
- text: '',
706
- selection: [1, 1]
707
- };
708
- }
709
- }
705
+ return {
706
+ text: pair ? quote + quote : "",
707
+ selection: [1,1]
708
+ };
710
709
  }
711
710
  }
712
711
  });
@@ -818,12 +817,35 @@ var FoldMode = exports.FoldMode = function(commentRegex) {
818
817
  oop.inherits(FoldMode, BaseFoldMode);
819
818
 
820
819
  (function() {
821
-
820
+
822
821
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
823
822
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
823
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
824
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
825
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
826
+ this._getFoldWidgetBase = this.getFoldWidget;
827
+ this.getFoldWidget = function(session, foldStyle, row) {
828
+ var line = session.getLine(row);
829
+
830
+ if (this.singleLineBlockCommentRe.test(line)) {
831
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
832
+ return "";
833
+ }
834
+
835
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
836
+
837
+ if (!fw && this.startRegionRe.test(line))
838
+ return "start"; // lineCommentRegionStart
839
+
840
+ return fw;
841
+ };
824
842
 
825
843
  this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
826
844
  var line = session.getLine(row);
845
+
846
+ if (this.startRegionRe.test(line))
847
+ return this.getCommentRegionBlock(session, line, row);
848
+
827
849
  var match = line.match(this.foldingStartMarker);
828
850
  if (match) {
829
851
  var i = match.index;
@@ -888,6 +910,29 @@ oop.inherits(FoldMode, BaseFoldMode);
888
910
 
889
911
  return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
890
912
  };
913
+
914
+ this.getCommentRegionBlock = function(session, line, row) {
915
+ var startColumn = line.search(/\s*$/);
916
+ var maxRow = session.getLength();
917
+ var startRow = row;
918
+
919
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
920
+ var depth = 1;
921
+ while (++row < maxRow) {
922
+ line = session.getLine(row);
923
+ var m = re.exec(line);
924
+ if (!m) continue;
925
+ if (m[1]) depth--;
926
+ else depth++;
927
+
928
+ if (!depth) break;
929
+ }
930
+
931
+ var endRow = row;
932
+ if (endRow > startRow) {
933
+ return new Range(startRow, startColumn, endRow, line.length);
934
+ }
935
+ };
891
936
 
892
937
  }).call(FoldMode.prototype);
893
938
 
@@ -963,7 +1008,7 @@ oop.inherits(Mode, TextMode);
963
1008
  var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
964
1009
  worker.attachToDocument(session.getDocument());
965
1010
 
966
- worker.on("jslint", function(results) {
1011
+ worker.on("annotate", function(results) {
967
1012
  session.setAnnotations(results.data);
968
1013
  });
969
1014
 
@@ -990,7 +1035,7 @@ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|al
990
1035
  var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
991
1036
  var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
992
1037
  var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
993
- var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
1038
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
994
1039
 
995
1040
  var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
996
1041
  var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
@@ -1254,7 +1299,7 @@ oop.inherits(Mode, TextMode);
1254
1299
  var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1255
1300
  worker.attachToDocument(session.getDocument());
1256
1301
 
1257
- worker.on("csslint", function(e) {
1302
+ worker.on("annotate", function(e) {
1258
1303
  session.setAnnotations(e.data);
1259
1304
  });
1260
1305
 
@@ -1279,6 +1324,9 @@ var oop = require("../lib/oop");
1279
1324
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1280
1325
 
1281
1326
  var XmlHighlightRules = function(normalize) {
1327
+
1328
+ var tagRegex = "[a-zA-Z][-_a-zA-Z0-9]*";
1329
+
1282
1330
  this.$rules = {
1283
1331
  start : [
1284
1332
  {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
@@ -1288,7 +1336,7 @@ var XmlHighlightRules = function(normalize) {
1288
1336
  },
1289
1337
  {
1290
1338
  token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
1291
- regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
1339
+ regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction",
1292
1340
  },
1293
1341
  {token : "comment.xml", regex : "<\\!--", next : "comment"},
1294
1342
  {
@@ -1304,7 +1352,7 @@ var XmlHighlightRules = function(normalize) {
1304
1352
 
1305
1353
  xml_decl : [{
1306
1354
  token : "entity.other.attribute-name.decl-attribute-name.xml",
1307
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
1355
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
1308
1356
  }, {
1309
1357
  token : "keyword.operator.decl-attribute-equals.xml",
1310
1358
  regex : "="
@@ -1340,7 +1388,7 @@ var XmlHighlightRules = function(normalize) {
1340
1388
  next: "pop"
1341
1389
  }, {
1342
1390
  token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
1343
- regex : "(<\\!)([-_a-zA-Z0-9]+)",
1391
+ regex : "(<\\!)(" + tagRegex + ")",
1344
1392
  push : [{
1345
1393
  token : "text",
1346
1394
  regex : "\\s+"
@@ -1376,7 +1424,7 @@ var XmlHighlightRules = function(normalize) {
1376
1424
 
1377
1425
  tag : [{
1378
1426
  token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
1379
- regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
1427
+ regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")",
1380
1428
  next: [
1381
1429
  {include : "attributes"},
1382
1430
  {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
@@ -1407,7 +1455,7 @@ var XmlHighlightRules = function(normalize) {
1407
1455
 
1408
1456
  attributes: [{
1409
1457
  token : "entity.other.attribute-name.xml",
1410
- regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
1458
+ regex : "(?:" + tagRegex + ":)?" + tagRegex + ""
1411
1459
  }, {
1412
1460
  token : "keyword.operator.attribute-equals.xml",
1413
1461
  regex : "="
@@ -1682,6 +1730,8 @@ var XmlBehaviour = function () {
1682
1730
  var token = iterator.getCurrentToken();
1683
1731
 
1684
1732
  if (token && token.type.indexOf("tag-close") !== -1) {
1733
+ if (token.value == "/>")
1734
+ return;
1685
1735
  while (token && token.type.indexOf("tag-name") === -1) {
1686
1736
  token = iterator.stepBackward();
1687
1737
  }
@@ -1935,9 +1985,6 @@ function is(token, type) {
1935
1985
  if (!tag || top.tagName == tag.tagName) {
1936
1986
  return stack.pop();
1937
1987
  }
1938
- else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
1939
- return;
1940
- }
1941
1988
  else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
1942
1989
  stack.pop();
1943
1990
  continue;
@@ -1963,6 +2010,8 @@ function is(token, type) {
1963
2010
  row: row,
1964
2011
  column: firstTag.start.column + firstTag.tagName.length + 2
1965
2012
  };
2013
+ if (firstTag.start.row == firstTag.end.row)
2014
+ start.column = firstTag.end.column;
1966
2015
  while (tag = this._readTagForward(iterator)) {
1967
2016
  if (tag.selfClosing) {
1968
2017
  if (!stack.length) {
@@ -2004,6 +2053,8 @@ function is(token, type) {
2004
2053
  this._pop(stack, tag);
2005
2054
  if (stack.length == 0) {
2006
2055
  tag.start.column += tag.tagName.length + 2;
2056
+ if (tag.start.row == tag.end.row && tag.start.column < tag.end.column)
2057
+ tag.start.column = tag.end.column;
2007
2058
  return Range.fromPoints(tag.start, end);
2008
2059
  }
2009
2060
  }