aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2019-05-02 17:04:24 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2019-05-02 17:04:24 -0400
commit0536dd6fa70d012d8c623302a8a19e61e5cc9510 (patch)
tree0ab1c893cd4fd0872893e2d1078b53412dc361b6
parent155731041ae1889b471476006293a4a671dcf9f3 (diff)
Added case-insensitive option to `textadept.editing.show_documentation()`.
-rw-r--r--modules/textadept/editing.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 98cf4687..7a7ef3c0 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -607,10 +607,12 @@ local api_docs
-- Symbols are determined by using `buffer.word_chars`.
-- @param pos Optional position of the symbol to show documentation for. If
-- omitted, the caret position is used.
+-- @param case_insensitive Optional flag that indicates whether or not to search
+-- API files case-insensitively for symbols. The default value is `false`.
-- @name show_documentation
-- @see api_files
-- @see buffer.word_chars
-function M.show_documentation(pos)
+function M.show_documentation(pos, case_insensitive)
if buffer:call_tip_active() then events.emit(events.CALL_TIP_CLICK) return end
local lang = buffer:get_lexer(true)
if not M.api_files[lang] then return end
@@ -623,6 +625,11 @@ function M.show_documentation(pos)
::lookup::
if symbol ~= '' then
local symbol_patt = '^'..symbol:gsub('(%p)', '%%%1')
+ if case_insensitive then
+ symbol_patt = symbol_patt:gsub('%a', function(ch)
+ return string.format('[%s%s]', ch:upper(), ch:lower())
+ end)
+ end
for i = 1, #M.api_files[lang] do
if lfs.attributes(M.api_files[lang][i]) then
for line in io.lines(M.api_files[lang][i]) do