File tree 2 files changed +32
-7
lines changed
2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -28,15 +28,18 @@ local debuginfo = function(variable_name)
28
28
return line
29
29
end
30
30
31
- local get_fix = function (filetype )
32
- if vim .tbl_contains (vim .tbl_keys (opts .filetypes ), filetype ) then
33
- return opts .filetypes [filetype ]
34
- else
31
+ local filetype_configured = function ()
32
+ local filetype =
33
+ vim .api .nvim_get_option_value (" filetype" , { scope = " local" })
34
+
35
+ if not vim .tbl_contains (vim .tbl_keys (opts .filetypes ), filetype ) then
35
36
vim .notify (
36
37
" Don't have debugprint configuration for filetype " .. filetype ,
37
38
vim .log .levels .WARN
38
39
)
39
- return nil
40
+ return false
41
+ else
42
+ return true
40
43
end
41
44
end
42
45
@@ -62,8 +65,9 @@ local debugprint_logic = function(o)
62
65
})
63
66
64
67
local current_line = vim .api .nvim_win_get_cursor (0 )[1 ]
65
- local filetype = vim .api .nvim_get_option_value (" filetype" , {})
66
- local fixes = get_fix (filetype )
68
+ local filetype =
69
+ vim .api .nvim_get_option_value (" filetype" , { scope = " local" })
70
+ local fixes = opts .filetypes [filetype ]
67
71
68
72
if fixes == nil then
69
73
return
111
115
112
116
local debugprint_cache = function (o )
113
117
if o and o .prerepeat == true then
118
+ if not filetype_configured () then
119
+ return
120
+ end
121
+
114
122
if o .variable == true then
115
123
o .variable_name = vim .fn .input (" Variable name: " )
116
124
end
Original file line number Diff line number Diff line change @@ -208,6 +208,23 @@ describe("can do various file types", function()
208
208
" bar" ,
209
209
})
210
210
end )
211
+
212
+ it (" don't prompt for a variable name with an unknown filetype" , function ()
213
+ set_lines ({
214
+ " foo" ,
215
+ " bar" ,
216
+ })
217
+
218
+ write_file (" foo" )
219
+ vim .api .nvim_win_set_cursor (0 , { 1 , 0 })
220
+ feedkeys (" dQp" )
221
+ assert .are .same (" Don't have debugprint configuration for filetype foo" , notify_message )
222
+
223
+ check_lines ({
224
+ " foo" ,
225
+ " bar" ,
226
+ })
227
+ end )
211
228
end )
212
229
213
230
describe (" can do indenting correctly" , function ()
You can’t perform that action at this time.
0 commit comments