Skip to content

Commit

Permalink
[ruby mode] Fixes /= operator for highlighting
Browse files Browse the repository at this point in the history
relates to #314
  • Loading branch information
bgilb authored and marijnh committed Feb 13, 2014
1 parent b19b03a commit e6dc18a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions mode/ruby/ruby.js
Expand Up @@ -34,6 +34,7 @@ CodeMirror.defineMode("ruby", function(config) {
if (ch == "`" || ch == "'" || ch == '"') {
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
} else if (ch == "/" && !stream.eol() && stream.peek() != " ") {
if (stream.eat("=")) return "operator";
return chain(readQuoted(ch, "string-2", true), stream, state);
} else if (ch == "%") {
var style = "string", embed = true;
Expand Down
11 changes: 11 additions & 0 deletions mode/ruby/test.js
@@ -0,0 +1,11 @@
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "ruby");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }

MT("divide_equal_operator",
"[variable bar] [operator /=] [variable foo]");

MT("divide_equal_operator_no_spacing",
"[variable foo][operator /=][number 42]");

})();
1 change: 1 addition & 0 deletions test/index.html
Expand Up @@ -82,6 +82,7 @@ <h2>Test Suite</h2>
<script src="../mode/xml/xml.js"></script>
<script src="../mode/htmlmixed/htmlmixed.js"></script>
<script src="../mode/ruby/ruby.js"></script>
<script src="../mode/ruby/test.js"></script>
<script src="../mode/haml/haml.js"></script>
<script src="../mode/haml/test.js"></script>
<script src="../mode/markdown/markdown.js"></script>
Expand Down

0 comments on commit e6dc18a

Please sign in to comment.