Browse Source

Avoid capturing disabled items in comments

Scott Lahteine 10 years ago
parent
commit
78b9428f4e
1 changed files with 9 additions and 6 deletions
  1. 9
    6
      Marlin/configurator/js/configurator.js

+ 9
- 6
Marlin/configurator/js/configurator.js View File

@@ -629,8 +629,8 @@ var configuratorApp = (function(){
629 629
       }
630 630
 
631 631
       if (info.type) {
632
-        var comment = '';
633 632
         // Get the end-of-line comment, if there is one
633
+        var comment = '';
634 634
         findDef = new RegExp('.*#define[ \\t].*/[/*]+[ \\t]*(.*)');
635 635
         if (info.line.search(findDef) >= 0) {
636 636
           comment = info.line.replace(findDef, '$1');
@@ -638,12 +638,15 @@ var configuratorApp = (function(){
638 638
         else {
639 639
           // Get all the comments immediately before the item
640 640
           var r, s;
641
-          findDef = new RegExp('([ \\t]*(//|#)[^\n]+\n){1,4}\\s{0,1}' + info.line, 'g');
641
+          findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line, 'g');
642 642
           if (r = findDef.exec(txt)) {
643
-            findDef = new RegExp('^[ \\t]*//+[ \\t]*([^#].*)[ \\t]*$', 'gm');
644
-            while((s = findDef.exec(r[0])) !== null) {
645
-              if (s[1].match(/\/\/[ \\t]*#define/) == null)
646
-                comment += s[1] + "\n";
643
+            findDef = new RegExp('^[ \\t]*(//+[ \\t]*.*)[ \\t]*$', 'gm');
644
+            while((s = findDef.exec(r[1])) !== null) {
645
+              if (s[1].match(/^\/\/[ \\t]*#define[ \\t]/) != null) {
646
+                comment = '';
647
+                break;
648
+              }
649
+              comment += s[1] + "\n";
647 650
             }
648 651
           }
649 652
         }

Loading…
Cancel
Save