-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Typing performance improvement #7193
Changes from 1 commit
8960b69
3803e25
17612b7
f41c78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -878,12 +878,15 @@ define(function (require, exports, module) { | |
| */ | ||
| Editor.prototype.getColOffset = function (pos) { | ||
| var line = this._codeMirror.getRange({line: pos.line, ch: 0}, pos), | ||
| tabSize = Editor.getTabSize(), | ||
| tabSize, | ||
| column = 0, | ||
| i; | ||
|
|
||
| for (i = 0; i < line.length; i++) { | ||
| if (line[i] === '\t') { | ||
| if (!tabSize) { | ||
| tabSize = Editor.getTabSize(); | ||
| } | ||
| column += (tabSize - (column % tabSize)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't let the tab size be 0, but if we just return 0 when it is 0, then this code won't break if we ever let it be 0. We know that the column will always be zero if the tabsize is 0. Does CM, lets you use 0, for tabsize? If so, maybe we can fix other issues like this and make the min be 0.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed the code so that if anyone did set I can't think of any reason why you'd want
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be just for consistency. After the validation code is merged, we could assume that the tab size will be always be a value between 1 and 10. But here you assume that it can be 0, but if it is 0, then
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I didn't notice that. Fixed. |
||
| } else { | ||
| column++; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if
tabSizeis 0?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.