File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -176,11 +176,32 @@ function command_invert(command)
176
176
end
177
177
end
178
178
179
- local value = mp .get_property (property )
180
- local semi = i == # command_list and " " or " ;"
181
-
182
179
if table .has (commands , command ) then
183
- invert = invert .. prefix .. " set " .. property .. " " .. value .. semi
180
+ local restore = true
181
+ local use_del = false
182
+ local value = mp .get_property_native (property )
183
+ local semi = i == # command_list and " " or " ; "
184
+
185
+ if type (value ) == ' number' then
186
+ value = tostring (value )
187
+ elseif type (value ) == ' boolean' then
188
+ value = value and ' yes' or ' no'
189
+ elseif type (value ) == ' string' then
190
+ value = ' "' .. value :replace (' "' , ' \\ "' ) .. ' "'
191
+ elseif type (value ) == ' nil' then
192
+ use_del = true
193
+ else
194
+ mp .msg .warn (" the value type of \" " .. property .. " \" is " .. type (value ) .. " , can't auto restore." )
195
+ restore = false
196
+ end
197
+
198
+ if restore then
199
+ if not use_del then
200
+ invert = invert .. prefix .. " set" .. " " .. property .. " " .. value .. semi
201
+ else
202
+ invert = invert .. prefix .. " del" .. " " .. property .. semi
203
+ end
204
+ end
184
205
else
185
206
mp .msg .warn (" \" " .. trimed .. " \" doesn't support auto restore." )
186
207
end
You can’t perform that action at this time.
0 commit comments