OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2010 Apple Inc. All rights reserved. | 3 * Copyright (C) 2010 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 this._gutterPanel.removeDecoration(lineNumber, decoration); | 101 this._gutterPanel.removeDecoration(lineNumber, decoration); |
102 }, | 102 }, |
103 | 103 |
104 markAndRevealRange: function(range) | 104 markAndRevealRange: function(range) |
105 { | 105 { |
106 this._mainPanel.markAndRevealRange(range); | 106 this._mainPanel.markAndRevealRange(range); |
107 }, | 107 }, |
108 | 108 |
109 highlightLine: function(lineNumber) | 109 highlightLine: function(lineNumber) |
110 { | 110 { |
| 111 if (typeof lineNumber !== "number" || lineNumber < 0) |
| 112 return; |
| 113 |
111 this._mainPanel.highlightLine(lineNumber); | 114 this._mainPanel.highlightLine(lineNumber); |
112 }, | 115 }, |
113 | 116 |
114 clearLineHighlight: function() | 117 clearLineHighlight: function() |
115 { | 118 { |
116 this._mainPanel.clearLineHighlight(); | 119 this._mainPanel.clearLineHighlight(); |
117 }, | 120 }, |
118 | 121 |
119 freeCachedElements: function() | 122 freeCachedElements: function() |
120 { | 123 { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 402 |
400 this._repaintAll(); | 403 this._repaintAll(); |
401 | 404 |
402 this.endDomUpdates(); | 405 this.endDomUpdates(); |
403 }, | 406 }, |
404 | 407 |
405 makeLineAChunk: function(lineNumber) | 408 makeLineAChunk: function(lineNumber) |
406 { | 409 { |
407 var chunkNumber = this._chunkNumberForLine(lineNumber); | 410 var chunkNumber = this._chunkNumberForLine(lineNumber); |
408 var oldChunk = this._textChunks[chunkNumber]; | 411 var oldChunk = this._textChunks[chunkNumber]; |
| 412 |
| 413 if (!oldChunk) { |
| 414 console.error("No chunk for line number: " + lineNumber); |
| 415 return; |
| 416 } |
| 417 |
409 if (oldChunk.linesCount === 1) | 418 if (oldChunk.linesCount === 1) |
410 return oldChunk; | 419 return oldChunk; |
411 | 420 |
412 return this._splitChunkOnALine(lineNumber, chunkNumber); | 421 return this._splitChunkOnALine(lineNumber, chunkNumber); |
413 }, | 422 }, |
414 | 423 |
415 _splitChunkOnALine: function(lineNumber, chunkNumber) | 424 _splitChunkOnALine: function(lineNumber, chunkNumber) |
416 { | 425 { |
417 this.beginDomUpdates(); | 426 this.beginDomUpdates(); |
418 | 427 |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 lines.push(this._textModel.line(i)); | 1903 lines.push(this._textModel.line(i)); |
1895 | 1904 |
1896 this.element.removeChildren(); | 1905 this.element.removeChildren(); |
1897 this.element.textContent = lines.join("\n"); | 1906 this.element.textContent = lines.join("\n"); |
1898 | 1907 |
1899 // The last empty line will get swallowed otherwise. | 1908 // The last empty line will get swallowed otherwise. |
1900 if (!lines[lines.length - 1]) | 1909 if (!lines[lines.length - 1]) |
1901 this.element.appendChild(document.createElement("br")); | 1910 this.element.appendChild(document.createElement("br")); |
1902 } | 1911 } |
1903 } | 1912 } |
OLD | NEW |