<commit_before>scriptencoding utf-8
" Author: w0rp <<EMAIL>>
" Author: <NAME> <<EMAIL>>
" Description: Shows lint message for the current line as virtualtext, if any

" Controls the milliseconds delay before showing a message.
let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
let s:cursor_timer = -1
let s:last_pos = [0, 0, 0]
let s:has_virt_text = 0

if has('nvim-0.3.2')
    let s:ns_id = nvim_create_namespace('ale')
    let s:has_virt_text = 1
elseif has('textprop') && has('popupwin')
    call prop_type_add('ale', {})
    let s:last_popup = -1
    let s:has_virt_text = 1
endif

if !hlexists('ALEVirtualTextError')
    highlight link ALEVirtualTextError ALEError
endif

if !hlexists('ALEVirtualTextStyleError')
    highlight link ALEVirtualTextStyleError ALEVirtualTextError
endif

if !hlexists('ALEVirtualTextWarning')
    highlight link ALEVirtualTextWarning ALEWarning
endif

if !hlexists('ALEVirtualTextStyleWarning')
    highlight link ALEVirtualTextStyleWarning ALEVirtualTextWarning
endif

if !hlexists('ALEVirtualTextInfo')
    highlight link ALEVirtualTextInfo ALEVirtualTextWarning
endif

function! ale#virtualtext#Clear() abort
    if !s:has_virt_text
        return
    endif

    let l:buffer = bufnr('')

    if has('nvim')
        call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
    else
        if s:last_popup != -1
            call prop_remove({'type': 'ale'})
            call popup_close(s:last_popup)
            let s:last_popup = -1
        endif
    endif
endfunction

function! ale#virtualtext#ShowMessage(message, hl_group) abort
    if !s:has_virt_text
        return
    endif

    let l:line = line('.')
    let l:buffer = bufnr('')
    let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')

    if has('nvim')
        call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:prefix.a:message, a:hl_group]], {})
    else
        let l:left_pad = col('$')
        call prop_add(l:line, l:left_pad, {
        \ 'type': 'ale',
        \})
        let s:last_popup = popup_create(l:prefix.a:message, {
        \ 'line': -1,
        \ 'padding': [0, 0, 0, 1],
        \ 'mask': [[1, 1, 1, 1]],
        \ 'textprop': 'ale',
        \ 'highlight': a:hl_group,
        \ 'fixed': 1,
        \ 'wrap': 0,
        \ 'zindex': 2
        \})
    endif
endfunction

function! s:StopCursorTimer() abort
    if s:cursor_timer != -1
        call timer_stop(s:cursor_timer)
        let s:cursor_timer = -1
    endif
endfunction

function! ale#virtualtext#ShowCursorWarning(...) abort
    if !g:ale_virtualtext_cursor
        return
    endif

    let l:buffer = bufnr('')

    if mode(1) isnot# 'n'
        return
    endif

    if ale#ShouldDoNothing(l:buffer)<commit_msg>Replace line breaks in virtual text with whitespace (#3949)<commit_after>scriptencoding utf-8
" Author: w0rp <<EMAIL>>
" Author: <NAME> <<EMAIL>>
" Description: Shows lint message for the current line as virtualtext, if any

" Controls the milliseconds delay before showing a message.
let g:ale_virtualtext_delay = get(g:, 'ale_virtualtext_delay', 10)
let s:cursor_timer = -1
let s:last_pos = [0, 0, 0]
let s:has_virt_text = 0

if has('nvim-0.3.2')
    let s:ns_id = nvim_create_namespace('ale')
    let s:has_virt_text = 1
elseif has('textprop') && has('popupwin')
    call prop_type_add('ale', {})
    let s:last_popup = -1
    let s:has_virt_text = 1
endif

if !hlexists('ALEVirtualTextError')
    highlight link ALEVirtualTextError ALEError
endif

if !hlexists('ALEVirtualTextStyleError')
    highlight link ALEVirtualTextStyleError ALEVirtualTextError
endif

if !hlexists('ALEVirtualTextWarning')
    highlight link ALEVirtualTextWarning ALEWarning
endif

if !hlexists('ALEVirtualTextStyleWarning')
    highlight link ALEVirtualTextStyleWarning ALEVirtualTextWarning
endif

if !hlexists('ALEVirtualTextInfo')
    highlight link ALEVirtualTextInfo ALEVirtualTextWarning
endif

function! ale#virtualtext#Clear() abort
    if !s:has_virt_text
        return
    endif

    let l:buffer = bufnr('')

    if has('nvim')
        call nvim_buf_clear_highlight(l:buffer, s:ns_id, 0, -1)
    else
        if s:last_popup != -1
            call prop_remove({'type': 'ale'})
            call popup_close(s:last_popup)
            let s:last_popup = -1
        endif
    endif
endfunction

function! ale#virtualtext#ShowMessage(message, hl_group) abort
    if !s:has_virt_text
        return
    endif

    let l:line = line('.')
    let l:buffer = bufnr('')
    let l:prefix = get(g:, 'ale_virtualtext_prefix', '> ')
    let l:msg = l:prefix.trim(substitute(a:message, '\n', ' ', 'g'))

    if has('nvim')
        call nvim_buf_set_virtual_text(l:buffer, s:ns_id, l:line-1, [[l:msg, a:hl_group]], {})
    else
        let l:left_pad = col('$')
        call prop_add(l:line, l:left_pad, {
        \ 'type': 'ale',
        \})
        let s:last_popup = popup_create(l:msg, {
        \ 'line': -1,
        \ 'padding': [0, 0, 0, 1],
        \ 'mask': [[1, 1, 1, 1]],
        \ 'textprop': 'ale',
        \ 'highlight': a:hl_group,
        \ 'fixed': 1,
        \ 'wrap': 0,
        \ 'zindex': 2
        \})
    endif
endfunction

function! s:StopCursorTimer() abort
    if s:cursor_timer != -1
        call timer_stop(s:cursor_timer)
        let s:cursor_timer = -1
    endif
endfunction

function! ale#virtualtext#ShowCursorWarning(...) abort
    if !g:ale_virtualtext_cursor
        return
    endif

    let l:buffer = bufnr('')

    if mode(1) isnot# 'n'
        return
    endif

    if ale#ShouldDoNothing(l:buffer)
{'fraction_non_alphanumeric': 0.12421014623578264, 'fraction_numerical': 0.01335981224047662, 'mean_word_length': 3.0765268579838114, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5753298', 'n_tokens_mistral': 1989, 'n_tokens_neox': 1914, 'n_words': 460}