vim: fix extracting message ids from list (#247)

The current method doesn't work because the list uses a fancy line
character (`│`) as the separator, not a regular pipe character (`|`).
Matching for the first number in the line instead solves the problem and
will continue to work regardless of what separator is used.
This commit is contained in:
Jason Cox 2021-10-29 01:10:02 -06:00 committed by GitHub
parent ae31f48bb5
commit aae7b5a310
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -326,9 +326,13 @@ function! s:bufwidth()
return width - numwidth - foldwidth - signwidth
endfunction
function! s:get_msg_id(line)
return matchstr(a:line, '[0-9]*')
endfunction
function! s:get_focused_msg_id()
try
return s:trim(split(getline("."), "|")[0])
return s:get_msg_id(getline("."))
catch
throw "message not found"
endtry
@ -336,7 +340,7 @@ endfunction
function! s:get_focused_msg_ids(from, to)
try
return join(map(range(a:from, a:to), "s:trim(split(getline(v:val), '|')[0])"), ",")
return join(map(range(a:from, a:to), "s:get_msg_id(getline(v:val))"), ",")
catch
throw "messages not found"
endtry