提交 d2e4fab7 编写于 作者: D Daniel Imms

Support wide character word links

Fixes #96416
上级 669b0dac
......@@ -37,21 +37,21 @@ export class TerminalWordLinkProvider implements ILinkProvider {
const end: IBufferCellPosition = { x: position.x, y: position.y };
// TODO: Support wrapping
// Expand to the left until a word separator is hit
const line = this._xterm.buffer.active.getLine(position.y - 1)!;
let text = '';
start.x++; // The hovered cell is considered first
for (let x = position.x; x > 0; x--) {
const char = line.getCell(x - 1)?.getChars();
if (!char) {
const cell = line.getCell(x - 1);
if (!cell) {
break;
}
const char = cell.getChars();
const config = this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
if (config.wordSeparators.indexOf(char) >= 0) {
if (cell.getWidth() !== 0 && config.wordSeparators.indexOf(char) >= 0) {
break;
}
start.x--;
start.x = x;
text = char + text;
}
......@@ -62,17 +62,17 @@ export class TerminalWordLinkProvider implements ILinkProvider {
}
// Expand to the right until a word separator is hit
// end.x++; // The hovered cell is considered first
for (let x = position.x + 1; x <= line.length; x++) {
const char = line.getCell(x - 1)?.getChars();
if (!char) {
const cell = line.getCell(x - 1);
if (!cell) {
break;
}
const char = cell.getChars();
const config = this._configurationService.getValue<ITerminalConfiguration>(TERMINAL_CONFIG_SECTION);
if (config.wordSeparators.indexOf(char) >= 0) {
if (cell.getWidth() !== 0 && config.wordSeparators.indexOf(char) >= 0) {
break;
}
end.x++;
end.x = x;
text += char;
}
......
......@@ -75,4 +75,14 @@ suite('Workbench - TerminalWordLinkProvider', () => {
await assertLink('[foo]', { range: [[1, 1], [5, 1]], text: '[foo]' });
await assertLink('{foo}', { range: [[1, 1], [5, 1]], text: '{foo}' });
});
test('should support wide characters', async () => {
await configurationService.setUserConfiguration('terminal', { integrated: { wordSeparators: ' []' } });
await assertLink('aabbccdd.txt ', { range: [[1, 1], [12, 1]], text: 'aabbccdd.txt' });
await assertLink('我是学生.txt ', { range: [[1, 1], [12, 1]], text: '我是学生.txt' });
await assertLink(' aabbccdd.txt ', { range: [[2, 1], [13, 1]], text: 'aabbccdd.txt' });
await assertLink(' 我是学生.txt ', { range: [[2, 1], [13, 1]], text: '我是学生.txt' });
await assertLink(' [aabbccdd.txt] ', { range: [[3, 1], [14, 1]], text: 'aabbccdd.txt' });
await assertLink(' [我是学生.txt] ', { range: [[3, 1], [14, 1]], text: '我是学生.txt' });
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册