1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 07:13:24 +03:00

Replace cursor attributes with defaults from current cell to enable correct handling of guibg=NONE and guig=NONE

This commit is contained in:
Johann Rudloff 2020-04-19 16:27:27 +02:00
parent 4be4923fee
commit bcb894acc9
2 changed files with 7 additions and 2 deletions

View File

@ -21,13 +21,17 @@ final class CellAttributesCollection {
init() { self.attributes[CellAttributesCollection.defaultAttributesId] = self.defaultAttributes }
func attributes(of id: Int) -> CellAttributes? {
return self.attributes(of: id, withDefaults: self.defaultAttributes)
}
func attributes(of id: Int, withDefaults defaults: CellAttributes) -> CellAttributes? {
if id == Int.max { return self.defaultAttributes.reversed }
let absId = abs(id)
guard let attrs = self.attributes[absId] else { return nil }
if id < 0 { return attrs.replacingDefaults(with: self.defaultAttributes).reversed }
return attrs.replacingDefaults(with: self.defaultAttributes)
return attrs.replacingDefaults(with: defaults)
}
func set(attributes: CellAttributes, for id: Int) {

View File

@ -100,7 +100,8 @@ extension NvimView {
guard let cursorAttrId = modeInfo.attrId,
let cursorShapeAttrs = self.cellAttributesCollection.attributes(
of: cursorAttrId
of: cursorAttrId,
withDefaults: cellAtCursorAttrs
) else {
self.log.error("Could not get the attributes" +
" for cursor in mode: \(mode) \(modeInfo)")