From dc535004e9670db733f6d65f89f20215750c29c4 Mon Sep 17 00:00:00 2001 From: myk002 Date: Wed, 5 Oct 2022 12:51:30 -0700 Subject: [PATCH] better formatting for ls output for tags --- docs/changelog.txt | 1 + library/lua/helpdb.lua | 6 ++++-- test/library/helpdb.lua | 8 ++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 72fb5906c..d00f4c246 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes ## Misc Improvements +- `ls`: indent tag listings and wrap them in the right column for better readability ## Documentation diff --git a/library/lua/helpdb.lua b/library/lua/helpdb.lua index ac6adb55d..d07445399 100644 --- a/library/lua/helpdb.lua +++ b/library/lua/helpdb.lua @@ -726,13 +726,15 @@ end local function list_entries(skip_tags, include, exclude) local entries = search_entries(include, exclude) for _,entry in ipairs(entries) do - print_columns(entry, get_entry_short_help(entry)) + local short_help = get_entry_short_help(entry) if not skip_tags then local tags = set_to_sorted_list(get_entry_tags(entry)) if #tags > 0 then - print((' tags: %s'):format(table.concat(tags, ', '))) + local taglist = table.concat(tags, ', ') + short_help = short_help .. NEWLINE .. 'tags: ' .. taglist end end + print_columns(entry, short_help) end if #entries == 0 then print('No matches.') diff --git a/test/library/helpdb.lua b/test/library/helpdb.lua index 067f35532..efa9e93d5 100644 --- a/test/library/helpdb.lua +++ b/test/library/helpdb.lua @@ -637,7 +637,7 @@ function test.ls() expect.eq(5, mock_print.call_count) expect.eq('inscript_docs in-file short description for inscript_docs.', mock_print.call_args[1][1]) - expect.eq(' tags: map', mock_print.call_args[2][1]) + expect.eq(' tags: map', mock_print.call_args[2][1]) expect.eq('nodoc_command cpp description.', mock_print.call_args[3][1]) expect.eq('nodocs_samename Nodocs samename.', @@ -652,15 +652,15 @@ function test.ls() expect.eq(6, mock_print.call_count) expect.eq('bindboxers Bind your boxers.', mock_print.call_args[1][1]) - expect.eq(' tags: armok, fort, units', + expect.eq(' tags: armok, fort, units', mock_print.call_args[2][1]) expect.eq('boxbinders Box your binders.', mock_print.call_args[3][1]) - expect.eq(' tags: armok, fort, units', + expect.eq(' tags: armok, fort, units', mock_print.call_args[4][1]) expect.eq('samename Samename.', mock_print.call_args[5][1]) - expect.eq(' tags: armok, fort, units', + expect.eq(' tags: armok, fort, units', mock_print.call_args[6][1]) end)