Don't scroll terminal search result if within viewport

This commit is contained in:
Logan Ramos
2019-08-16 10:50:44 -04:00
parent 95ff15457b
commit 85444def9f
+7 -3
View File
@@ -343,9 +343,13 @@ export class SearchAddon implements ITerminalAddon {
return false;
}
terminal.select(result.col, result.row, result.term.length);
let scroll = result.row - terminal.buffer.viewportY;
scroll = scroll - Math.floor(terminal.rows / 2);
terminal.scrollLines(scroll);
// If it is not in the viewport then we scroll else it just gets selected
if (result.row > (terminal.buffer.viewportY + terminal.rows) || result.row < terminal.buffer.viewportY) {
let scroll = result.row - terminal.buffer.viewportY;
scroll = scroll - Math.floor(terminal.rows / 2);
terminal.scrollLines(scroll);
console.log('scrolling');
}
return true;
}
}