Skip to content

Commit 330d143

Browse files
authored
fix previous code block action (microsoft#210594)
fix microsoft#210592
1 parent 86637ca commit 330d143

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/vs/workbench/contrib/accessibility/browser/accessibleView.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,16 @@ export class AccessibleView extends Disposable {
296296
if (!this._codeBlocks?.length || !position) {
297297
return;
298298
}
299-
const codeBlockIndex = this._codeBlocks.findIndex(c => type === 'previous' ? c.endLine >= position.lineNumber : c.startLine > position.lineNumber);
300-
if (codeBlockIndex === -1) {
299+
let codeBlock;
300+
const codeBlocks = this._codeBlocks.slice();
301+
if (type === 'previous') {
302+
codeBlock = codeBlocks.reverse().find(c => c.endLine < position.lineNumber);
303+
} else {
304+
codeBlock = codeBlocks.find(c => c.startLine > position.lineNumber);
305+
}
306+
if (!codeBlock) {
301307
return;
302308
}
303-
const codeBlock = this._codeBlocks[codeBlockIndex];
304309
this.setPosition(new Position(codeBlock.startLine, 1), true);
305310
}
306311

0 commit comments

Comments
 (0)