commit 04665e4eb17807332a35591b090edd1b30637330 parent e183a5eb4b45ce2f0a066a4e3685052b614dbf69 Author: Matthew Horan <matt@matthoran.com> Date: Tue, 22 Jan 2019 22:43:35 -0500 Use lastIndexOf instead of loop for tab complete Diffstat:
M | src/usecase/buffers/ui/BufferContainer.tsx | | | 7 | ++----- |
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/usecase/buffers/ui/BufferContainer.tsx b/src/usecase/buffers/ui/BufferContainer.tsx @@ -118,11 +118,8 @@ class BufferContainer extends React.Component<Props, State> { if (!this.tabCompleteInProgress) { this.tabCompleteWordEnd = selection.start; - this.tabCompleteWordStart = this.tabCompleteWordEnd; - while (this.tabCompleteWordStart > 0 && - textValue.charAt(this.tabCompleteWordStart - 1) != ' ') { - this.tabCompleteWordStart--; - } + this.tabCompleteWordStart = textValue.lastIndexOf(' ', + this.tabCompleteWordEnd - 1) + 1; if (this.tabCompleteWordStart == this.tabCompleteWordEnd) return;