提交 920a07f9 编写于 作者: M meganrogge

fix implications of changing end line of lists and add test for selecting...

fix implications of changing end line of lists and add test for selecting content under header then subheaders and their contents
上级 a154625c
......@@ -167,7 +167,13 @@ function createFencedRange(token: Token, document: vscode.TextDocument, parent?:
} else if (parent?.range.isEqual(blockRange.range)) {
return new vscode.SelectionRange(childRange, parent);
} else {
return new vscode.SelectionRange(childRange, blockRange);
if (parent?.parent?.range.contains(blockRange.range)) {
// in a list that's end range has been shortened
blockRange.parent = parent.parent;
return new vscode.SelectionRange(childRange, blockRange);
} else {
return new vscode.SelectionRange(childRange, blockRange);
}
}
}
......
......@@ -88,7 +88,7 @@ suite.only('markdown.SmartSelect', () => {
`- item 3`,
`- item 4`));
assertNestedRangesEqual(ranges![0], [1, 2], [0, 3]);
assertNestedRangesEqual(ranges![0], [1, 1], [0, 3]);
});
test('Smart select list with fenced code block', async () => {
const ranges = await getSelectionRangesForDocument(
......@@ -112,8 +112,8 @@ suite.only('markdown.SmartSelect', () => {
`- ${CURSOR}item 3`,
`- item 4`));
assertNestedRangesEqual(ranges![0], [0, 1], [0, 5]);
assertNestedRangesEqual(ranges![1], [4, 5], [0, 5]);
assertNestedRangesEqual(ranges![0], [0, 0], [0, 5]);
assertNestedRangesEqual(ranges![1], [4, 4], [0, 5]);
});
test('Smart select nested block quotes', async () => {
const ranges = await getSelectionRangesForDocument(
......@@ -212,6 +212,21 @@ suite.only('markdown.SmartSelect', () => {
assertNestedRangesEqual(ranges![0], [2, 3], [1, 6], [0, 6]);
});
test('Smart select content under header then subheaders and their content', async () => {
const ranges = await getSelectionRangesForDocument(
joinLines(
`# main header 1`,
``,
`- list ${CURSOR}`,
`paragraph`,
`## sub header`,
``,
`content 2`,
`# main header 2`));
assertNestedRangesEqual(ranges![0], [2, 3], [1, 4], [1, 7], [0, 7]);
});
});
function assertNestedRangesEqual(range: vscode.SelectionRange, ...expectedRanges: [number, number][]) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册