Only scroll history when cursor is on first or last row

Needs to be on first to go up and on last to go down
This commit is contained in:
Nachtalb 2021-04-30 23:53:57 +02:00
parent 0fb6dae8a6
commit c66f9c885e
No known key found for this signature in database
GPG key ID: E48DF13C07055D92

View file

@ -140,18 +140,28 @@ export default {
return;
}
const onRow = (
this.$refs.input.value.slice(null, this.$refs.input.selectionStart).match(/\n/g) ||
[]
).length;
const totalRows = (this.$refs.input.value.match(/\n/g) || []).length;
const {channel} = this;
if (channel.inputHistoryPosition === 0) {
channel.inputHistory[channel.inputHistoryPosition] = channel.pendingMessage;
}
if (key === "up") {
if (key === "up" && onRow === 0) {
if (channel.inputHistoryPosition < channel.inputHistory.length - 1) {
channel.inputHistoryPosition++;
} else {
return;
}
} else if (channel.inputHistoryPosition > 0) {
} else if (key === "down" && channel.inputHistoryPosition > 0 && onRow === totalRows) {
channel.inputHistoryPosition--;
} else {
return;
}
channel.pendingMessage = channel.inputHistory[channel.inputHistoryPosition];