Skip to content

Commit

Permalink
引用メッセージへ飛べるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
kamecha committed Aug 7, 2024
1 parent 34abbb5 commit 4499122
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion autoload/traqvim/message.vim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ function traqvim#message#get_message() abort
return traqvim#message#get_message_buf(curline, bufnr("%"))
endfunction

function traqvim#message#get_message_quote() abort
let curline = line(".")
let message = traqvim#message#get_message_buf(curline, bufnr("%"))
let quote = message->get("quote", [])
if empty(quote)
return {}
endif
let quotePos = copy(message)->get("position")->get("quote", [])
if empty(quotePos)
return {}
endif
let relativePos = curline - message.position["start"]
silent let quotePos->filter({ _, v -> v.start <= relativePos && relativePos <= v.end })
if len(quotePos) == 0
return {}
else
return quote[quotePos[0]->get("index")]
endif
endfunction

function traqvim#message#message_prev() abort
let cur = traqvim#message#get_message()
if empty(cur)
Expand Down Expand Up @@ -44,7 +64,8 @@ function traqvim#message#goto_message() abort
if empty(message)
return
endif
call denops#request('traqvim', 'timelineMessage', [message])
let quote = traqvim#message#get_message_quote()
call denops#request('traqvim', 'timelineMessage', [quote != #{} ? quote : message])
endfunction

function traqvim#message#registerYankMessageLink() abort
Expand Down

0 comments on commit 4499122

Please sign in to comment.