Implement tab completion
JavaScript (ES6), 75 bytes

(s,a)=&gt;/^(.*).*(\n\1.*)*$/.exec(a.filter(e=&gt;e.startsWith(s)).join`
`)[1]||s


Explanation: Filters on all matching prefixes, then joins with newlines and matches against a regex that finds the longest common prefix of all lines. If there are no prefixes then the regex returns an empty string in which case we simply return the original string.