Do not navigate history when autocompleting

This commit is contained in:
Pavel Djundik 2018-09-09 16:03:37 +03:00
parent 4c103b467b
commit f526aa8b8b
3 changed files with 6 additions and 5 deletions

View File

@ -116,7 +116,7 @@ export default {
}); });
inputTrap.bind(["up", "down"], (e, key) => { inputTrap.bind(["up", "down"], (e, key) => {
if (e.target.selectionStart !== e.target.selectionEnd) { if (this.$root.isAutoCompleting || e.target.selectionStart !== e.target.selectionEnd) {
return; return;
} }

View File

@ -21,6 +21,7 @@ module.exports = {
Mousetrap(input.get(0)).unbind("tab", "keydown"); Mousetrap(input.get(0)).unbind("tab", "keydown");
textcomplete.destroy(); textcomplete.destroy();
enabled = false; enabled = false;
vueApp.isAutoCompleting = false;
} }
}, },
}; };
@ -169,7 +170,6 @@ const backgroundColorStrategy = {
function enableAutocomplete(inputRef) { function enableAutocomplete(inputRef) {
enabled = true; enabled = true;
let autocompleting = false;
let tabCount = 0; let tabCount = 0;
let lastMatch = ""; let lastMatch = "";
let currentMatches = []; let currentMatches = [];
@ -186,7 +186,7 @@ function enableAutocomplete(inputRef) {
}); });
Mousetrap(input.get(0)).bind("tab", (e) => { Mousetrap(input.get(0)).bind("tab", (e) => {
if (autocompleting) { if (vueApp.isAutoCompleting) {
return; return;
} }
@ -252,11 +252,11 @@ function enableAutocomplete(inputRef) {
}); });
textcomplete.on("show", () => { textcomplete.on("show", () => {
autocompleting = true; vueApp.isAutoCompleting = true;
}); });
textcomplete.on("hidden", () => { textcomplete.on("hidden", () => {
autocompleting = false; vueApp.isAutoCompleting = false;
}); });
$("#form").on("submit.tabcomplete", () => { $("#form").on("submit.tabcomplete", () => {

View File

@ -26,6 +26,7 @@ const vueApp = new Vue({
connectionError: false, connectionError: false,
fileUploadEnabled: false, fileUploadEnabled: false,
isNotified: false, isNotified: false,
isAutoCompleting: false,
appName: document.title, appName: document.title,
activeChannel: null, activeChannel: null,
networks: [], networks: [],