Skip to content

Commit 6faf2c7

Browse files
committed
fix: correct vim.fn.has() comparisons to use explicit == 1
1 parent 1d6b57f commit 6faf2c7

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

lua/flutter-tools/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local function validate_prefs(prefs)
3636
end
3737
)
3838
end
39-
if vim.fn.has("nvim-0.11") then
39+
if vim.fn.has("nvim-0.11") == 1 then
4040
vim.validate("outline", prefs.outline, "table", true)
4141
vim.validate("dev_log", prefs.dev_log, "table", true)
4242
vim.validate("closing_tags", prefs.closing_tags, "table", true)

lua/flutter-tools/lsp/color/utils.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end
3232
---@return RGB rgb_table
3333
--- FIXME: this currently does not support transparent backgrounds. Need a replacement for bg_rgb
3434
function M.rgba_to_rgb(rgba, bg_rgb)
35-
if vim.fn.has("nvim-0.11") then
35+
if vim.fn.has("nvim-0.11") == 1 then
3636
vim.validate("rgba", rgba, "table", true)
3737
vim.validate("bg_rgb", bg_rgb, "table", false)
3838
vim.validate("r", rgba.r, "number", true)
@@ -70,7 +70,7 @@ end
7070
---@param rgb RGB with keys 'r', 'g', 'b' in [0,255]
7171
---@return string 6 digit hex representing the rgb params
7272
local function rgb_to_hex(rgb)
73-
if vim.fn.has("nvim-0.11") then
73+
if vim.fn.has("nvim-0.11") == 1 then
7474
vim.validate("rgb", rgb, "table", false)
7575
vim.validate("r", rgb.r, "number", false)
7676
vim.validate("g", rgb.g, "number", false)
@@ -98,7 +98,7 @@ function M.rgba_to_hex(rgba, bg_rgb) return rgb_to_hex(M.rgba_to_rgb(rgba, bg_rg
9898
---@param rgb_24bit number 24-bit RGB value
9999
---@return RGB
100100
function M.decode_24bit_rgb(rgb_24bit)
101-
if vim.fn.has("nvim-0.11") then
101+
if vim.fn.has("nvim-0.11") == 1 then
102102
vim.validate("rgb_24bit", rgb_24bit, "number", true)
103103
else
104104
vim.validate({ rgb_24bit = { rgb_24bit, "number", true } })
@@ -219,7 +219,7 @@ end
219219
---@param color_infos table of `ColorInformation` objects to highlight.
220220
-- See https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor
221221
function M.buf_color(client_id, bufnr, color_infos, _)
222-
if vim.fn.has("nvim-0.11") then
222+
if vim.fn.has("nvim-0.11") == 1 then
223223
vim.validate("bufnr", bufnr, "number", true)
224224
vim.validate("color_infos", color_infos, "table", true)
225225
else
@@ -250,7 +250,7 @@ end
250250
---@param client_id number client id
251251
---@param bufnr number buffer id
252252
function M.buf_clear_color(client_id, bufnr)
253-
if vim.fn.has("nvim-0.11") then
253+
if vim.fn.has("nvim-0.11") == 1 then
254254
vim.validate("client_id", client_id, "number", true)
255255
vim.validate("bufnr", bufnr, "number", true)
256256
else

lua/flutter-tools/utils/path.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function M.is_descendant(root, path)
9393
end
9494

9595
function M.search_ancestors(startpath, func)
96-
if vim.fn.has("nvim-0.11") then
96+
if vim.fn.has("nvim-0.11") == 1 then
9797
vim.validate("func", func, "function")
9898
else
9999
vim.validate({ func = { func, "function" } })

0 commit comments

Comments
 (0)