@@ -2,6 +2,7 @@ local require = require("noice.util.lazy")
2
2
3
3
local Util = require (" noice.util" )
4
4
local View = require (" noice.view" )
5
+ local Manager = require (" noice.message.manager" )
5
6
6
7
--- @class NoiceNotifyOptions
7
8
--- @field title string
@@ -16,7 +17,7 @@ local defaults = {
16
17
}
17
18
18
19
--- @class NotifyInstance
19
- --- @field notify fun ( msg : string , level ?: string | number , opts ?: table ): notify.Record }
20
+ --- @field notify fun ( msg : string ? , level ?: string | number , opts ?: table ): notify.Record }
20
21
21
22
--- @alias notify.RenderFun fun ( buf : buffer , notif : Notification , hl : NotifyBufHighlights , config : notify.Config )
22
23
@@ -25,7 +26,6 @@ local defaults = {
25
26
--- @field buf ? number
26
27
--- @field notif table<NotifyInstance , notify.Record>
27
28
--- @field super NoiceView
28
- --- @field _notifs table<number , any>
29
29
--- @diagnostic disable-next-line : undefined-field
30
30
local NotifyView = View :extend (" NotifyView" )
31
31
52
52
function NotifyView :init (opts )
53
53
NotifyView .super .init (self , opts )
54
54
self .notif = {}
55
- self ._notifs = {}
56
55
end
57
56
58
57
function NotifyView :is_available ()
@@ -129,7 +128,7 @@ function NotifyView:_notify(msg)
129
128
on_close = function ()
130
129
self .notif [instance ] = nil
131
130
for _ , m in ipairs (msg .messages ) do
132
- self . _notifs [ m . id ] = nil
131
+ m . opts . notify_id = nil
133
132
end
134
133
self .win = nil
135
134
end ,
@@ -139,14 +138,22 @@ function NotifyView:_notify(msg)
139
138
if msg .opts then
140
139
opts = vim .tbl_deep_extend (" force" , opts , msg .opts )
141
140
if type (msg .opts .replace ) == " table" then
142
- opts .replace = self ._notifs [msg .opts .replace .id ]
141
+ local m = Manager .get_by_id (msg .opts .replace .id )
142
+ opts .replace = m and m .opts .notify_id or nil
143
143
end
144
144
end
145
145
146
- local id = instance .notify (msg .content , level , opts )
146
+ --- @type string ?
147
+ local content = msg .content
148
+
149
+ if msg .opts and msg .opts .is_nil then
150
+ content = nil
151
+ end
152
+
153
+ local id = instance .notify (content , level , opts )
147
154
self .notif [instance ] = id
148
155
for _ , m in ipairs (msg .messages ) do
149
- self . _notifs [ m . id ] = id
156
+ m . opts . notify_id = id
150
157
end
151
158
end
152
159
0 commit comments