Fix "$1" when completing nicks outside of textcomplete menu
Fixes #3716
This commit is contained in:
parent
e8ba4f4fb9
commit
4e6bd9e943
@ -45,19 +45,8 @@ const nicksStrategy = {
|
|||||||
template([string]) {
|
template([string]) {
|
||||||
return string;
|
return string;
|
||||||
},
|
},
|
||||||
replace([, original], position = 1) {
|
replace([, original]) {
|
||||||
// If no postfix specified, return autocompleted nick as-is
|
return "$1" + replaceNick(original);
|
||||||
if (!store.state.settings.nickPostfix) {
|
|
||||||
return "$1" + original;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there is whitespace in the input already, append space to nick
|
|
||||||
if (position > 0 && /\s/.test(store.state.activeChannel.channel.pendingMessage)) {
|
|
||||||
return "$1" + original + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
// If nick is first in the input, append specified postfix
|
|
||||||
return "$1" + original + store.state.settings.nickPostfix;
|
|
||||||
},
|
},
|
||||||
index: 2,
|
index: 2,
|
||||||
};
|
};
|
||||||
@ -205,8 +194,8 @@ function enableAutocomplete(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const position = input.selectionStart - lastMatch.length;
|
const position = input.selectionStart - lastMatch.length;
|
||||||
const newMatch = nicksStrategy.replace(
|
const newMatch = replaceNick(
|
||||||
[0, currentMatches[tabCount % currentMatches.length]],
|
currentMatches[tabCount % currentMatches.length],
|
||||||
position
|
position
|
||||||
);
|
);
|
||||||
const remainder = text.substr(input.selectionStart);
|
const remainder = text.substr(input.selectionStart);
|
||||||
@ -272,6 +261,21 @@ function enableAutocomplete(input) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceNick(original, position = 1) {
|
||||||
|
// If no postfix specified, return autocompleted nick as-is
|
||||||
|
if (!store.state.settings.nickPostfix) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is whitespace in the input already, append space to nick
|
||||||
|
if (position > 0 && /\s/.test(store.state.activeChannel.channel.pendingMessage)) {
|
||||||
|
return original + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// If nick is first in the input, append specified postfix
|
||||||
|
return original + store.state.settings.nickPostfix;
|
||||||
|
}
|
||||||
|
|
||||||
function fuzzyGrep(term, array) {
|
function fuzzyGrep(term, array) {
|
||||||
const results = fuzzy.filter(term, array, {
|
const results = fuzzy.filter(term, array, {
|
||||||
pre: "<b>",
|
pre: "<b>",
|
||||||
|
Loading…
Reference in New Issue
Block a user