Skip to content

Commit

Permalink
Make autocomplete scan up to 2 times the terminal height number of rows.
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Feb 19, 2021
1 parent a169fac commit f2389c4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions extensions/Autocomplete/src/Autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
let log: Logger = null;
let context: ExtensionContext = null;

const MAX_SCAN_ROWS = 50;

export function activate(_context: ExtensionContext): any {
context = _context;
log = context.logger;
Expand Down Expand Up @@ -49,14 +47,16 @@ function collectWords(): string[] {
let blockIndex = blocks.length -1;
const screenLines: string[] = [];

while (screenLines.length < MAX_SCAN_ROWS && blockIndex >= 0) {
const maxScanRows = context.window.activeTerminal.screen.height * 2;

while (screenLines.length < maxScanRows && blockIndex >= 0) {
const block = blocks[blockIndex];
if (block.type === TerminalOutputType) {
const details = <TerminalOutputDetails> block.details;
if (details.hasPty) {
scanScreen(context.window.activeTerminal.screen, screenLines);
scanScreen(context.window.activeTerminal.screen, screenLines, maxScanRows);
}
scanScreen(details.scrollback, screenLines);
scanScreen(details.scrollback, screenLines, maxScanRows);
}
blockIndex--;
}
Expand All @@ -68,8 +68,8 @@ function collectWords(): string[] {
return words;
}

function scanScreen(screen: Screen, screenLines: string[]): void {
for(let i=screen.height-1; i>=0 && screenLines.length<MAX_SCAN_ROWS; i--) {
function scanScreen(screen: Screen, screenLines: string[], maxScanRows: number): void {
for(let i=screen.height-1; i>=0 && screenLines.length<maxScanRows; i--) {
const line = screen.getLineText(i);
if (line.trim() !== "") {
screenLines.push(line);
Expand Down

0 comments on commit f2389c4

Please sign in to comment.