Fix commands for buffers whose fullname contain whitespace
Use pointers if Weechat version is recent enough (1.0+). Otherwise, not marking stuff as read is probably the lesser evil than crashing weechat...
This commit is contained in:
parent
0e0484b5f0
commit
78b33798c6
2 changed files with 17 additions and 1 deletions
|
@ -246,7 +246,7 @@ weechat.factory('connection',
|
||||||
*/
|
*/
|
||||||
var sendMessage = function(message) {
|
var sendMessage = function(message) {
|
||||||
ngWebsockets.send(weeChat.Protocol.formatInput({
|
ngWebsockets.send(weeChat.Protocol.formatInput({
|
||||||
buffer: models.getActiveBuffer().fullName,
|
buffer: models.getActiveBufferReference(),
|
||||||
data: message
|
data: message
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
16
js/models.js
16
js/models.js
|
@ -451,6 +451,22 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
return activeBuffer;
|
return activeBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a reference to the currently active buffer that
|
||||||
|
* WeeChat understands without crashing, even if it's invalid
|
||||||
|
*
|
||||||
|
* @return active buffer pointer (WeeChat 1.0+) or fullname (older versions)
|
||||||
|
*/
|
||||||
|
this.getActiveBufferReference = function() {
|
||||||
|
if (this.version !== null && parseInt(this.version.charAt(0)) >= 1) {
|
||||||
|
// pointers are being validated, they're more reliable than
|
||||||
|
// fullName (e.g. if fullName contains spaces)
|
||||||
|
return activeBuffer.id;
|
||||||
|
} else {
|
||||||
|
return activeBuffer.fullName;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the previous current active buffer
|
* Returns the previous current active buffer
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue