提交 ab90818c 编写于 作者: M Martin Aeschlimann

[folding] Cannot read property 'length' of undefined. Fixes #46171

上级 53332ed1
...@@ -292,9 +292,9 @@ export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocume ...@@ -292,9 +292,9 @@ export function getJavascriptMode(documentRegions: LanguageModelCache<HTMLDocume
let endLine = curr.end.line; let endLine = curr.end.line;
if (startLine < endLine && startLine >= rangeStartLine && endLine < rangeEndLine) { if (startLine < endLine && startLine >= rangeStartLine && endLine < rangeEndLine) {
let foldingRange: FoldingRange = { startLine, endLine }; let foldingRange: FoldingRange = { startLine, endLine };
let match = document.getText(curr).match(/^\s*\/(\/\s*#(?:end)?region\b)|([\*\/])/); let match = document.getText(curr).match(/^\s*\/(?:(\/\s*#(?:end)?region\b)|(\*|\/))/);
if (match) { if (match) {
foldingRange.type = match[1].length ? FoldingRangeType.Region : FoldingRangeType.Comment; foldingRange.type = match[1] ? FoldingRangeType.Region : FoldingRangeType.Comment;
} }
ranges.push(foldingRange); ranges.push(foldingRange);
} }
......
...@@ -130,7 +130,7 @@ suite('Object Folding', () => { ...@@ -130,7 +130,7 @@ suite('Object Folding', () => {
/* 6*/' };', /* 6*/' };',
/* 7*/'</script>', /* 7*/'</script>',
/* 8*/'<script>', /* 8*/'<script>',
/* 9*/' test(() => {', /* 9*/' test(() => { // hello',
/*10*/' f();', /*10*/' f();',
/*11*/' });', /*11*/' });',
/*12*/'</script>', /*12*/'</script>',
...@@ -206,7 +206,7 @@ suite('Object Folding', () => { ...@@ -206,7 +206,7 @@ suite('Object Folding', () => {
/*2*/'</div>', /*2*/'</div>',
]; ];
assertRanges(input, [r(0, 1)]); assertRanges(input, [r(0, 1)]);
}); });
test('Fold intersecting region', () => { test('Fold intersecting region', () => {
let input = [ let input = [
...@@ -218,7 +218,7 @@ suite('Object Folding', () => { ...@@ -218,7 +218,7 @@ suite('Object Folding', () => {
/*5*/'<!-- #endregion -->', /*5*/'<!-- #endregion -->',
]; ];
assertRanges(input, [r(0, 3)]); assertRanges(input, [r(0, 3)]);
}); });
test('Test limit', () => { test('Test limit', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册