Merge pull request #261 from lorenzhs/nickclickfix
Improve nick clicking in buffer
This commit is contained in:
commit
d95e85b017
1 changed files with 7 additions and 5 deletions
|
@ -860,15 +860,16 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
var addColon = newValue.length === 0;
|
var addColon = newValue.length === 0;
|
||||||
if (newValue.length > 0) {
|
if (newValue.length > 0) {
|
||||||
// Try to determine if it's a sequence of nicks
|
// Try to determine if it's a sequence of nicks
|
||||||
if (newValue.charAt(newValue.length - 1) === ':') {
|
var trimmedValue = newValue.trim();
|
||||||
|
if (trimmedValue.charAt(trimmedValue.length - 1) === ':') {
|
||||||
// get last word
|
// get last word
|
||||||
var lastSpace = newValue.lastIndexOf(' ') + 1;
|
var lastSpace = trimmedValue.lastIndexOf(' ') + 1;
|
||||||
var lastWord = newValue.slice(lastSpace, newValue.length - 1).trim();
|
var lastWord = trimmedValue.slice(lastSpace, trimmedValue.length - 1);
|
||||||
var nicklist = models.getActiveBuffer().flatNicklist();
|
var nicklist = models.getActiveBuffer().flatNicklist();
|
||||||
// check against nicklist to see if it's a list of highlights
|
// check against nicklist to see if it's a list of highlights
|
||||||
if (nicklist.indexOf(lastWord) !== -1) {
|
if (nicklist.indexOf(lastWord) !== -1) {
|
||||||
// It's another highlight!
|
// It's another highlight!
|
||||||
newValue = newValue.slice(0, newValue.length - 1) + ' ';
|
newValue = newValue.slice(0, newValue.lastIndexOf(':')) + ' ';
|
||||||
addColon = true;
|
addColon = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -885,6 +886,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
newValue += ': ';
|
newValue += ': ';
|
||||||
}
|
}
|
||||||
input.value = newValue;
|
input.value = newValue;
|
||||||
|
input.focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Calculate number of lines to fetch
|
// Calculate number of lines to fetch
|
||||||
|
|
Loading…
Reference in a new issue