fix: Resolve many display issues with the dropdown theme (#95)

This commit is contained in:
Dave Lage
2020-09-17 21:50:25 -04:00
committed by GitHub
2 changed files with 16 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ end
local layout_strategies = {} local layout_strategies = {}
local log = require("telescope.log") local log = require("telescope.log")
local resolve = require("telescope.config.resolve") local resolve = require("telescope.config.resolve")
--[[ --[[
+-----------------+---------------------+ +-----------------+---------------------+
| | | | | |
@@ -123,7 +124,7 @@ end
-- Check if there are any borders. Right now it's a little raw as -- Check if there are any borders. Right now it's a little raw as
-- there are a few things that contribute to the border -- there are a few things that contribute to the border
local is_borderless = function(opts) local is_borderless = function(opts)
if opts.window.border == false then return true end if opts.window.border == false then return true else return false end
end end
layout_strategies.center = function(self, columns, lines, prompt_title) layout_strategies.center = function(self, columns, lines, prompt_title)
@@ -133,8 +134,17 @@ layout_strategies.center = function(self, columns, lines, prompt_title)
local prompt = initial_options.prompt local prompt = initial_options.prompt
local max_results = self.max_results or 15 local max_results = self.max_results or 15
local width = self.width or 70 local width = resolve.resolve_width(function(self, max_columns)
local width_opts = resolve.win_option(self.window.width)
if width_opts.preview > max_columns then
return max_columns
end
return width_opts.preview
end)(self, columns)
-- All width's will likely result in the same width. Can be more specific with inquiry.
local max_width = (width > columns and columns or width) local max_width = (width > columns and columns or width)
prompt.height = 1 prompt.height = 1
@@ -152,7 +162,7 @@ layout_strategies.center = function(self, columns, lines, prompt_title)
results.line = prompt.line + prompt.height + (bs * 2) results.line = prompt.line + prompt.height + (bs * 2)
preview.line = 1 preview.line = 1
preview.height = math.floor(prompt.line - 2) preview.height = math.floor(prompt.line - (2 + bs))
if not self.previewer or columns < self.preview_cutoff then if not self.previewer or columns < self.preview_cutoff then
preview.height = 0 preview.height = 0

View File

@@ -17,11 +17,12 @@ function themes.get_dropdown(opts)
layout_strategy = "center", layout_strategy = "center",
results_title = false, results_title = false,
preview_title = "Preview", preview_title = "Preview",
border = false, width = 70,
borderchars = { borderchars = {
{ '', '', '', '', '', '', '', ''},
prompt = {"", "", " ", "", "", "", "", ""}, prompt = {"", "", " ", "", "", "", "", ""},
results = {"", "", "", "", "", "", "", ""}, results = {"", "", "", "", "", "", "", ""},
preview = {"=", "=", "", "", "", "", "", ""} preview = { '', '', '', '', '', '', '', ''},
}, },
} }