From fb462c91a4a4089a05eeb83a3d6b5333d4385c2d Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 21 Aug 2017 15:28:40 -0700 Subject: [PATCH] Ensure returned spans are ordered by start --- src/services/outliningElementsCollector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 82ac22e644c..59f8e9f5549 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -13,7 +13,7 @@ namespace ts.OutliningElementsCollector { walk(sourceFile); gatherRegions(); - return elements; + return elements.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start); /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean, useFullStart: boolean) {