Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: Source/devtools/front_end/cm/comment.js

Issue 658563005: DevTools: [CodeMirror] roll comment plugin to @7dfbf42 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE 2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3 3
4 (function(mod) { 4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS 5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror")); 6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD 7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod); 8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env 9 else // Plain browser env
10 mod(CodeMirror); 10 mod(CodeMirror);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } else { 102 } else {
103 self.replaceRange(endString, to); 103 self.replaceRange(endString, to);
104 self.replaceRange(startString, from); 104 self.replaceRange(startString, from);
105 } 105 }
106 }); 106 });
107 }); 107 });
108 108
109 CodeMirror.defineExtension("uncomment", function(from, to, options) { 109 CodeMirror.defineExtension("uncomment", function(from, to, options) {
110 if (!options) options = noOptions; 110 if (!options) options = noOptions;
111 var self = this, mode = self.getModeAt(from); 111 var self = this, mode = self.getModeAt(from);
112 var end = Math.min(to.line, self.lastLine()), start = Math.min(from.line, en d); 112 var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
113 113
114 // Try finding line comments 114 // Try finding line comments
115 var lineString = options.lineComment || mode.lineComment, lines = []; 115 var lineString = options.lineComment || mode.lineComment, lines = [];
116 var pad = options.padding == null ? " " : options.padding, didSomething; 116 var pad = options.padding == null ? " " : options.padding, didSomething;
117 lineComment: { 117 lineComment: {
118 if (!lineString) break lineComment; 118 if (!lineString) break lineComment;
119 for (var i = start; i <= end; ++i) { 119 for (var i = start; i <= end; ++i) {
120 var line = self.getLine(i); 120 var line = self.getLine(i);
121 var found = line.indexOf(lineString); 121 var found = line.indexOf(lineString);
122 if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)) )) found = -1; 122 if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)) )) found = -1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 var line = self.getLine(i), found = line.indexOf(lead); 174 var line = self.getLine(i), found = line.indexOf(lead);
175 if (found == -1 || nonWS.test(line.slice(0, found))) continue; 175 if (found == -1 || nonWS.test(line.slice(0, found))) continue;
176 var foundEnd = found + lead.length; 176 var foundEnd = found + lead.length;
177 if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length; 177 if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
178 self.replaceRange("", Pos(i, found), Pos(i, foundEnd)); 178 self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
179 } 179 }
180 }); 180 });
181 return true; 181 return true;
182 }); 182 });
183 }); 183 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698