mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Try to keep one blank line after markdown block element folds
Fixes #58187
This commit is contained in:
@@ -88,7 +88,10 @@ export default class MarkdownFoldingProvider implements vscode.FoldingRangeProvi
|
||||
const multiLineListItems = tokens.filter(isFoldableToken);
|
||||
return multiLineListItems.map(listItem => {
|
||||
const start = listItem.map[0];
|
||||
const end = listItem.map[1] - 1;
|
||||
let end = listItem.map[1] - 1;
|
||||
if (document.lineAt(end).isEmptyOrWhitespace && end >= start + 1) {
|
||||
end = end - 1;
|
||||
}
|
||||
return new vscode.FoldingRange(start, end);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ d`);
|
||||
assert.strictEqual(firstFold.end, 3);
|
||||
});
|
||||
|
||||
test('Should fold if list has multiple lines of content', async () => {
|
||||
test('lists folds should span multiple lines of content', async () => {
|
||||
const folds = await getFoldsForDocument(`a
|
||||
- This list item\n spans multiple\n lines.`);
|
||||
assert.strictEqual(folds.length, 1);
|
||||
@@ -123,6 +123,18 @@ d`);
|
||||
assert.strictEqual(firstFold.end, 3);
|
||||
});
|
||||
|
||||
test('List should leave single blankline before new element', async () => {
|
||||
const folds = await getFoldsForDocument(`- a
|
||||
a
|
||||
|
||||
|
||||
b`);
|
||||
assert.strictEqual(folds.length, 1);
|
||||
const firstFold = folds[0];
|
||||
assert.strictEqual(firstFold.start, 0);
|
||||
assert.strictEqual(firstFold.end, 3);
|
||||
});
|
||||
|
||||
test('Should fold fenced code blocks', async () => {
|
||||
const folds = await getFoldsForDocument(`~~~ts
|
||||
a
|
||||
|
||||
Reference in New Issue
Block a user