Skip to content

Commit

Permalink
(all) Update code to better handle default nil values.
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Feb 7, 2023
1 parent dd198c5 commit 398cbc1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lua/mini/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,11 @@ end
--- Default: `true`.
MiniCompletion.complete_twostage = function(fallback, force)
if H.is_disabled() then return end
if fallback == nil then fallback = true end
if force == nil then force = true end

H.stop_completion()
H.completion.fallback, H.completion.force = fallback or true, force or true
H.completion.fallback, H.completion.force = fallback, force
H.trigger_twostep()
end

Expand Down
2 changes: 0 additions & 2 deletions lua/mini/map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,6 @@ end
---@param use_previous_cursor boolean|nil Whether to focus on source window at
--- original cursor position (the one prior focusing on map window).
MiniMap.toggle_focus = function(use_previous_cursor)
if use_previous_cursor == nil then use_previous_cursor = false end

if not H.is_window_open() then return end
local cur_win, map_win = vim.api.nvim_get_current_win(), H.get_current_map_win()

Expand Down
12 changes: 6 additions & 6 deletions lua/mini/starter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ end
---@return __starter_section_fun
MiniStarter.sections.sessions = function(n, recent)
n = n or 5
recent = recent == nil and true or recent
if recent == nil then recent = true end

return function()
if _G.MiniSessions == nil then
Expand Down Expand Up @@ -509,8 +509,8 @@ end
---@return __starter_section_fun
MiniStarter.sections.recent_files = function(n, current_dir, show_path)
n = n or 5
current_dir = current_dir == nil and false or current_dir
show_path = show_path == nil and true or show_path
if current_dir == nil then current_dir = false end
if show_path == nil then show_path = true end

if current_dir then vim.cmd('au DirChanged * lua MiniStarter.refresh()') end

Expand Down Expand Up @@ -619,7 +619,7 @@ end
---@return function Content hook.
MiniStarter.gen_hook.adding_bullet = function(bullet, place_cursor)
bullet = bullet or ''
place_cursor = place_cursor == nil and true or place_cursor
if place_cursor == nil then place_cursor = true end
return function(content)
local coords = MiniStarter.content_coords(content, 'item')
-- Go backwards to avoid conflict when inserting units
Expand Down Expand Up @@ -697,8 +697,8 @@ end
---
---@return function Content hook.
MiniStarter.gen_hook.aligning = function(horizontal, vertical)
horizontal = horizontal == nil and 'left' or horizontal
vertical = vertical == nil and 'top' or vertical
horizontal = horizontal or 'left'
vertical = vertical or 'top'

local horiz_coef = ({ left = 0, center = 0.5, right = 1.0 })[horizontal]
local vert_coef = ({ top = 0, center = 0.5, bottom = 1.0 })[vertical]
Expand Down

0 comments on commit 398cbc1

Please sign in to comment.