From 9f6449f71170efca905f1b052ec727a2bac81878 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke <marijnh@gmail.com>
Date: Mon, 9 Jan 2012 09:07:23 +0100
Subject: [PATCH] [ruby mode] Add heuristic to distinguish operator-/ from
 regexp

This isn't really correct, but covers most cases. Someone with more
knowledge of Ruby's syntax will have to chime in what the real
solution would look like.

Issue #314
---
 mode/ruby/ruby.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mode/ruby/ruby.js b/mode/ruby/ruby.js
index ddc1a6547..6898bb929 100644
--- a/mode/ruby/ruby.js
+++ b/mode/ruby/ruby.js
@@ -31,7 +31,8 @@ CodeMirror.defineMode("ruby", function(config, parserConfig) {
     }
     if (stream.eatSpace()) return null;
     var ch = stream.next();
-    if (ch == "`" || ch == "'" || ch == '"' || ch == "/") {
+    if (ch == "`" || ch == "'" || ch == '"' ||
+        (ch == "/" && !stream.eol() && stream.peek() != " ")) {
       return chain(readQuoted(ch, "string", ch == '"'), stream, state);
     } else if (ch == "%") {
       var style, embed = false;
-- 
GitLab