Skip to content

Commit

Permalink
Set cursor to found pattern line
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Nov 6, 2019
1 parent 33ea17b commit e8fd835
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fx.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,23 @@ module.exports = function start(filename, source) {
screen.render()
}
}

// Set cursor to current path.
// We need timeout here to give our terminal some time.
// Without timeout first cursorPos call does not working,
// it looks like an ugly hack and it is an ugly hack.
setTimeout(() => {
for (let [k, v] of index) {
if (v === currentPath) {
let y = box.getScreenNumber(k) - box.childBase
if (y <= 0) {
y = 0
}
const line = box.getScreenLine(y + box.childBase)
program.cursorPos(y, line.search(/\S/))
}
}
}, 100)
}
}

Expand Down

0 comments on commit e8fd835

Please sign in to comment.