fix: adjust layout positioning for new indexing (#1260)

This commit is contained in:
Luke Kershaw
2021-09-19 17:23:37 +01:00
committed by GitHub
parent 02bc88e6d6
commit 007b6e3061

View File

@@ -334,16 +334,16 @@ layout_strategies.horizontal = make_documented_layout(
local width_padding = math.floor((max_columns - width) / 2) local width_padding = math.floor((max_columns - width) / 2)
-- Default value is false, to use the normal horizontal layout -- Default value is false, to use the normal horizontal layout
if not layout_config.mirror then if not layout_config.mirror then
results.col = width_padding + bs results.col = width_padding + bs + 1
prompt.col = results.col prompt.col = results.col
preview.col = results.col + results.width + 1 + bs preview.col = results.col + results.width + 1 + bs
else else
preview.col = width_padding + bs preview.col = width_padding + bs + 1
prompt.col = preview.col + preview.width + 1 + bs prompt.col = preview.col + preview.width + 1 + bs
results.col = preview.col + preview.width + 1 + bs results.col = preview.col + preview.width + 1 + bs
end end
preview.line = math.floor((max_lines - height) / 2) + bs preview.line = math.floor((max_lines - height) / 2) + bs + 1
if layout_config.prompt_position == "top" then if layout_config.prompt_position == "top" then
prompt.line = preview.line prompt.line = preview.line
results.line = prompt.line + prompt.height + 1 + bs results.line = prompt.line + prompt.height + 1 + bs
@@ -435,20 +435,18 @@ layout_strategies.center = make_documented_layout(
-- Align the prompt and results so halfway up the screen is -- Align the prompt and results so halfway up the screen is
-- in the middle of this combined block -- in the middle of this combined block
prompt.line = (max_lines / 2) - ((results.height + (2 * bs)) / 2) prompt.line = (max_lines / 2) - ((results.height + (2 * bs)) / 2) + 1
results.line = prompt.line + 1 + bs results.line = prompt.line + 1 + bs
preview.line = 1 preview.line = 2
if self.previewer and max_lines >= layout_config.preview_cutoff then if self.previewer and max_lines >= layout_config.preview_cutoff then
preview.height = math.floor(prompt.line - (2 + bs)) preview.height = math.floor(prompt.line - (3 + bs))
else else
preview.height = 0 preview.height = 0
end end
results.col = math.ceil((max_columns / 2) - (width / 2) + bs) results.col, preview.col, prompt.col = 0, 0, 0 -- all centered
prompt.col = results.col
preview.col = results.col
if tbln then if tbln then
prompt.line = prompt.line + 1 prompt.line = prompt.line + 1
@@ -552,11 +550,11 @@ layout_strategies.cursor = make_documented_layout(
top_left.col = max_columns - width top_left.col = max_columns - width
end end
prompt.line = top_left.line prompt.line = top_left.line + 1
results.line = prompt.line + bs + 1 results.line = prompt.line + bs + 1
preview.line = prompt.line preview.line = prompt.line
prompt.col = top_left.col prompt.col = top_left.col + 1
results.col = prompt.col results.col = prompt.col
preview.col = results.col + (bs * 2) + results.width preview.col = results.col + (bs * 2) + results.width
@@ -638,16 +636,15 @@ layout_strategies.vertical = make_documented_layout(
prompt.height = 1 prompt.height = 1
results.height = height - preview.height - prompt.height - h_space results.height = height - preview.height - prompt.height - h_space
local width_padding = math.floor((max_columns - width) / 2) + 1 results.col, preview.col, prompt.col = 0, 0, 0 -- all centered
results.col, preview.col, prompt.col = width_padding, width_padding, width_padding
local height_padding = math.floor((max_lines - height) / 2) local height_padding = math.floor((max_lines - height) / 2)
if not layout_config.mirror then if not layout_config.mirror then
preview.line = height_padding + bs preview.line = height_padding + bs + 1
results.line = (preview.height == 0) and preview.line or preview.line + preview.height + (1 + bs) results.line = (preview.height == 0) and preview.line or preview.line + preview.height + (1 + bs)
prompt.line = results.line + results.height + (1 + bs) prompt.line = results.line + results.height + (1 + bs)
else else
prompt.line = height_padding + bs prompt.line = height_padding + bs + 1
results.line = prompt.line + prompt.height + (1 + bs) results.line = prompt.line + prompt.height + (1 + bs)
preview.line = results.line + results.height + (1 + bs) preview.line = results.line + results.height + (1 + bs)
end end
@@ -729,15 +726,15 @@ layout_strategies.current_buffer = make_documented_layout("current_buffer", {
local line = win_position[1] local line = win_position[1]
if self.previewer then if self.previewer then
preview.line = height_padding + line preview.line = height_padding + line + 1
results.line = preview.line + preview.height + (1 + bs) results.line = preview.line + preview.height + (1 + bs)
prompt.line = results.line + results.height + (1 + bs) prompt.line = results.line + results.height + (1 + bs)
else else
results.line = height_padding + line results.line = height_padding + line + 1
prompt.line = results.line + results.height + (1 + bs) prompt.line = results.line + results.height + (1 + bs)
end end
local col = win_position[2] + width_padding local col = win_position[2] + width_padding + 1
preview.col, results.col, prompt.col = col, col, col preview.col, results.col, prompt.col = col, col, col
return { return {
@@ -794,18 +791,18 @@ layout_strategies.bottom_pane = make_documented_layout(
end end
-- Line -- Line
prompt.line = max_lines - results.height - (1 + bs) prompt.line = max_lines - results.height - (1 + bs) + 1
results.line = prompt.line + 1 results.line = prompt.line + 1
preview.line = results.line + bs preview.line = results.line + bs
-- Col -- Col
prompt.col = bs prompt.col = 0 -- centered
if layout_config.mirror and preview.width > 0 then if layout_config.mirror and preview.width > 0 then
results.col = preview.width + (3 * bs) results.col = preview.width + (3 * bs) + 1
preview.col = bs preview.col = bs + 1
else else
results.col = bs results.col = bs + 1
preview.col = results.width + (3 * bs) preview.col = results.width + (3 * bs) + 1
end end
if tbln then if tbln then