Revert "Preserve location on first and last line when scrolling through inputs" (#4367)
This reverts commit c5f6b4617f
.
This commit is contained in:
parent
315198ac0b
commit
af96f7771c
@ -140,10 +140,11 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldValue = this.$refs.input.value;
|
const onRow = (
|
||||||
const oldPosition = this.$refs.input.selectionStart;
|
this.$refs.input.value.slice(null, this.$refs.input.selectionStart).match(/\n/g) ||
|
||||||
const onRow = (oldValue.slice(null, oldPosition).match(/\n/g) || []).length;
|
[]
|
||||||
const totalRows = (oldValue.match(/\n/g) || []).length;
|
).length;
|
||||||
|
const totalRows = (this.$refs.input.value.match(/\n/g) || []).length;
|
||||||
|
|
||||||
const {channel} = this;
|
const {channel} = this;
|
||||||
|
|
||||||
@ -164,29 +165,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
channel.pendingMessage = channel.inputHistory[channel.inputHistoryPosition];
|
channel.pendingMessage = channel.inputHistory[channel.inputHistoryPosition];
|
||||||
const newValue = channel.pendingMessage;
|
this.$refs.input.value = channel.pendingMessage;
|
||||||
this.$refs.input.value = newValue;
|
|
||||||
|
|
||||||
let newPosition;
|
|
||||||
|
|
||||||
if (key === "up") {
|
|
||||||
const lastIndexOfNewLine = newValue.lastIndexOf("\n");
|
|
||||||
const lastLine = newValue.slice(null, lastIndexOfNewLine);
|
|
||||||
newPosition =
|
|
||||||
oldPosition > lastLine.length
|
|
||||||
? newValue.length
|
|
||||||
: lastIndexOfNewLine + oldPosition + 1;
|
|
||||||
} else {
|
|
||||||
const lastPositionOnFirstLine =
|
|
||||||
newValue.indexOf("\n") === -1 ? newValue.length + 1 : newValue.indexOf("\n");
|
|
||||||
const relativeRowPos = oldPosition - oldValue.lastIndexOf("\n") - 1;
|
|
||||||
newPosition =
|
|
||||||
relativeRowPos > lastPositionOnFirstLine
|
|
||||||
? lastPositionOnFirstLine
|
|
||||||
: relativeRowPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$refs.input.setSelectionRange(newPosition, newPosition);
|
|
||||||
this.setInputSize();
|
this.setInputSize();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user