Decrement line ends if they end with a carriage return. (#31220)

* Decrement line ends if they end with a carriage return.

* Changed handling of newlines and inlined regex operation.

* fixed misname of hintSpan

* added tests

* revert inline of regex match and use getLineEndOfPosition

* fixed lint error and changed a silly thing in tests
This commit is contained in:
Jesse Trinity authored and GitHub committed 2019-07-25 21:29:12 -07:00
1 parent 772bee5e84
commit 599e36a068
2 files changed
+24 -3

No files matched your search

+2 -3
View File
@@ -71,9 +71,8 @@ namespace ts.OutliningElementsCollector {
function addRegionOutliningSpans(sourceFile: SourceFile, out: Push<OutliningSpan>): void {
const regions: OutliningSpan[] = [];
const lineStarts = sourceFile.getLineStarts();
for (let i = 0; i < lineStarts.length; i++) {
const currentLineStart = lineStarts[i];
const lineEnd = i + 1 === lineStarts.length ? sourceFile.getEnd() : lineStarts[i + 1] - 1;
for (const currentLineStart of lineStarts) {
const lineEnd = sourceFile.getLineEndOfPosition(currentLineStart);
const lineText = sourceFile.text.substring(currentLineStart, lineEnd);
const result = isRegionDelimiter(lineText);
if (!result || isInComment(sourceFile, currentLineStart)) {