@@ -60,6 +60,32 @@ local function blend_color_with_neovim_bg(color_name, blend)
6060 return string.format (' #%02x%02x%02x' , r , g , b )
6161end
6262
63+ local function dedupe_strings (str )
64+ if not str then
65+ return str
66+ end
67+ local seen = {}
68+ local result = {}
69+ for s in str :gmatch (' [^%s,]+' ) do
70+ if not seen [s ] then
71+ seen [s ] = true
72+ table.insert (result , s )
73+ end
74+ end
75+ return table.concat (result , ' ' )
76+ end
77+
78+ local function get_error_message (err )
79+ if type (err ) == ' string' then
80+ -- Match first occurrence of :something: and capture rest
81+ local message = err :match (' ^[^:]+:[^:]+:(.+)' ) or err
82+ -- Trim whitespace
83+ message = message :match (' ^%s*(.-)%s*$' )
84+ return dedupe_strings (message )
85+ end
86+ return dedupe_strings (vim .inspect (err ))
87+ end
88+
6389local function find_lines_between_separator (lines , pattern , at_least_one )
6490 local line_count = # lines
6591 local separator_line_start = 1
@@ -393,17 +419,6 @@ function M.ask(prompt, config, source)
393419 M .stop (true , config )
394420 end
395421
396- local function get_error_message (err )
397- if type (err ) == ' string' then
398- -- Match first occurrence of :something: and capture rest
399- local message = err :match (' ^[^:]+:[^:]+:(.+)' ) or err
400- -- Trim whitespace
401- message = message :match (' ^%s*(.-)%s*$' )
402- return message
403- end
404- return vim .inspect (err )
405- end
406-
407422 local function on_error (err )
408423 log .error (vim .inspect (err ))
409424 vim .schedule (function ()
0 commit comments