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

Side by Side Diff: Source/devtools/front_end/source_frame/CodeMirrorTextEditor.js

Issue 669043002: DevTools: Fix the way search works when switching between editor tabs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Comments addressed 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 }, 548 },
549 549
550 wasShown: function() 550 wasShown: function()
551 { 551 {
552 if (this._wasOnceShown) 552 if (this._wasOnceShown)
553 return; 553 return;
554 this._wasOnceShown = true; 554 this._wasOnceShown = true;
555 this._codeMirror.refresh(); 555 this._codeMirror.refresh();
556 }, 556 },
557 557
558 willHide: function()
559 {
560 delete this._editorSizeInSync;
561 },
562
558 _guessIndentationLevel: function() 563 _guessIndentationLevel: function()
559 { 564 {
560 var tabRegex = /^\t+/; 565 var tabRegex = /^\t+/;
561 var tabLines = 0; 566 var tabLines = 0;
562 var indents = {}; 567 var indents = {};
563 var maxScanLines = 1000; 568 var maxScanLines = 1000;
564 function processLine(lineHandle) 569 function processLine(lineHandle)
565 { 570 {
566 var text = lineHandle.text; 571 var text = lineHandle.text;
567 if (text.length === 0 || !WebInspector.TextUtils.isSpaceChar(text[0] )) 572 if (text.length === 0 || !WebInspector.TextUtils.isSpaceChar(text[0] ))
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 var height = parentElement.offsetHeight - this.element.offsetTop; 1180 var height = parentElement.offsetHeight - this.element.offsetTop;
1176 this._codeMirror.setSize(width, height); 1181 this._codeMirror.setSize(width, height);
1177 this._updatePaddingBottom(width, height); 1182 this._updatePaddingBottom(width, height);
1178 this._codeMirror.scrollTo(scrollLeft, scrollTop); 1183 this._codeMirror.scrollTo(scrollLeft, scrollTop);
1179 }, 1184 },
1180 1185
1181 onResize: function() 1186 onResize: function()
1182 { 1187 {
1183 this._autocompleteController.finishAutocomplete(); 1188 this._autocompleteController.finishAutocomplete();
1184 this._resizeEditor(); 1189 this._resizeEditor();
1190 this._editorSizeInSync = true;
1191 if (this._selectionSetScheduled) {
1192 delete this._selectionSetScheduled;
1193 this.setSelection(this._lastSelection);
1194 }
1185 }, 1195 },
1186 1196
1187 /** 1197 /**
1188 * @param {!WebInspector.TextRange} range 1198 * @param {!WebInspector.TextRange} range
1189 * @param {string} text 1199 * @param {string} text
1190 * @return {!WebInspector.TextRange} 1200 * @return {!WebInspector.TextRange}
1191 */ 1201 */
1192 editRange: function(range, text) 1202 editRange: function(range, text)
1193 { 1203 {
1194 var pos = WebInspector.CodeMirrorUtils.toPos(range); 1204 var pos = WebInspector.CodeMirrorUtils.toPos(range);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 { 1390 {
1381 return this._lastSelection; 1391 return this._lastSelection;
1382 }, 1392 },
1383 1393
1384 /** 1394 /**
1385 * @param {!WebInspector.TextRange} textRange 1395 * @param {!WebInspector.TextRange} textRange
1386 */ 1396 */
1387 setSelection: function(textRange) 1397 setSelection: function(textRange)
1388 { 1398 {
1389 this._lastSelection = textRange; 1399 this._lastSelection = textRange;
1400 if (!this._editorSizeInSync) {
1401 this._selectionSetScheduled = true;
1402 return;
1403 }
1390 var pos = WebInspector.CodeMirrorUtils.toPos(textRange); 1404 var pos = WebInspector.CodeMirrorUtils.toPos(textRange);
1391 this._codeMirror.setSelection(pos.start, pos.end); 1405 this._codeMirror.setSelection(pos.start, pos.end);
1392 }, 1406 },
1393 1407
1394 /** 1408 /**
1395 * @param {!Array.<!WebInspector.TextRange>} ranges 1409 * @param {!Array.<!WebInspector.TextRange>} ranges
1396 * @param {number=} primarySelectionIndex 1410 * @param {number=} primarySelectionIndex
1397 */ 1411 */
1398 setSelections: function(ranges, primarySelectionIndex) 1412 setSelections: function(ranges, primarySelectionIndex)
1399 { 1413 {
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 function tokenOverride(superToken, stream, state) 2456 function tokenOverride(superToken, stream, state)
2443 { 2457 {
2444 var token = superToken(stream, state); 2458 var token = superToken(stream, state);
2445 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) : token; 2459 return token ? tokenPrefix + token.split(/ +/).join(" " + tokenPrefix) : token;
2446 } 2460 }
2447 } 2461 }
2448 2462
2449 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-") ; 2463 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("css", "css-") ;
2450 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript", "js-"); 2464 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("javascript", "js-");
2451 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-") ; 2465 WebInspector.CodeMirrorTextEditor._overrideModeWithPrefixedTokens("xml", "xml-") ;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/components/SearchableView.js ('k') | Source/devtools/front_end/source_frame/SourceFrame.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698