@ -1181,19 +1181,44 @@ void Source::LanguageProtocolView::show_type_tooltips(const Gdk::Rectangle &rect
type_tooltips . clear ( ) ;
type_tooltips . clear ( ) ;
auto token_iters = get_token_iters ( get_buffer ( ) - > get_iter_at_offset ( offset ) ) ;
auto token_iters = get_token_iters ( get_buffer ( ) - > get_iter_at_offset ( offset ) ) ;
type_tooltips . emplace_back ( this , token_iters . first , token_iters . second , [ this , offset , contents = std : : move ( contents ) ] ( Tooltip & tooltip ) {
type_tooltips . emplace_back ( this , token_iters . first , token_iters . second , [ this , offset , contents = std : : move ( contents ) ] ( Tooltip & tooltip ) mutable {
bool first = true ;
bool first = true ;
for ( auto & content : contents ) {
if ( language_id = = " python " ) {
if ( ! first )
std : : string function ;
tooltip . buffer - > insert_at_cursor ( " \n \n " ) ;
for ( auto & content : contents ) {
first = false ;
if ( ! first )
if ( content . kind = = " plaintext " | | content . kind . empty ( ) | | ( language_id = = " python " & & content . kind = = " markdown " ) ) // Python might support markdown in the future
tooltip . buffer - > insert_at_cursor ( " \n \n " ) ;
tooltip . insert_with_links_tagged ( content . value ) ;
first = false ;
else if ( content . kind = = " markdown " )
if ( content . kind = = " python " ) {
tooltip . insert_markdown ( content . value ) ;
tooltip . insert_code ( content . value , content . kind ) ;
else
auto pos = content . value . find ( ' ( ' ) ;
tooltip . insert_code ( content . value , content . kind ) ;
if ( pos ! = std : : string : : npos )
tooltip . remove_trailing_newlines ( ) ;
function = content . value . substr ( 0 , pos + 1 ) ;
}
else {
if ( ! function . empty ( ) ) {
while ( starts_with ( content . value , function ) ) {
auto pos = content . value . find ( " \n \n " ) ;
content . value . erase ( 0 , pos ! = std : : string : : npos ? pos + 2 : pos ) ;
}
}
tooltip . insert_with_links_tagged ( content . value ) ;
}
}
}
else {
for ( auto & content : contents ) {
if ( ! first )
tooltip . buffer - > insert_at_cursor ( " \n \n " ) ;
first = false ;
if ( content . kind = = " plaintext " | | content . kind . empty ( ) | | ( language_id = = " python " & & content . kind = = " markdown " ) ) // Python might support markdown in the future
tooltip . insert_with_links_tagged ( content . value ) ;
else if ( content . kind = = " markdown " )
tooltip . insert_markdown ( content . value ) ;
else
tooltip . insert_code ( content . value , content . kind ) ;
tooltip . remove_trailing_newlines ( ) ;
}
}
}
# ifdef JUCI_ENABLE_DEBUG
# ifdef JUCI_ENABLE_DEBUG
@ -1730,20 +1755,33 @@ void Source::LanguageProtocolView::setup_autocomplete() {
auto autocomplete = autocomplete_rows [ index ] ;
auto autocomplete = autocomplete_rows [ index ] ;
if ( autocomplete . detail . empty ( ) & & autocomplete . documentation . empty ( ) )
if ( autocomplete . detail . empty ( ) & & autocomplete . documentation . empty ( ) )
return nullptr ;
return nullptr ;
return [ this , autocomplete = std : : move ( autocomplete ) ] ( Tooltip & tooltip ) {
return [ this , autocomplete = std : : move ( autocomplete ) ] ( Tooltip & tooltip ) mutable {
if ( ! autocomplete . detail . empty ( ) ) {
if ( language_id = = " python " ) {
tooltip . insert_code ( autocomplete . detail , language ) ;
auto pos = autocomplete . insert . find ( ' ( ' ) ;
tooltip . remove_trailing_newlines ( ) ;
if ( pos ! = std : : string : : npos ) {
auto function = autocomplete . insert . substr ( 0 , pos + 1 ) ;
while ( starts_with ( autocomplete . documentation , function ) ) {
auto pos = autocomplete . documentation . find ( " \n \n " ) ;
autocomplete . documentation . erase ( 0 , pos ! = std : : string : : npos ? pos + 2 : pos ) ;
}
}
tooltip . insert_with_links_tagged ( autocomplete . documentation ) ;
}
}
if ( ! autocomplete . documentation . empty ( ) ) {
else {
if ( tooltip . buffer - > size ( ) > 0 )
if ( ! autocomplete . detail . empty ( ) ) {
tooltip . buffer - > insert_at_cursor ( " \n \n " ) ;
tooltip . insert_code ( autocomplete . detail , language ) ;
if ( autocomplete . kind = = " plaintext " | | autocomplete . kind . empty ( ) | | ( language_id = = " python " & & autocomplete . kind = = " markdown " ) ) // Python might support markdown in the future
tooltip . remove_trailing_newlines ( ) ;
tooltip . insert_with_links_tagged ( autocomplete . documentation ) ;
}
else if ( autocomplete . kind = = " markdown " )
if ( ! autocomplete . documentation . empty ( ) ) {
tooltip . insert_markdown ( autocomplete . documentation ) ;
if ( tooltip . buffer - > size ( ) > 0 )
else
tooltip . buffer - > insert_at_cursor ( " \n \n " ) ;
tooltip . insert_code ( autocomplete . documentation , autocomplete . kind ) ;
if ( autocomplete . kind = = " plaintext " | | autocomplete . kind . empty ( ) | | ( language_id = = " python " & & autocomplete . kind = = " markdown " ) ) // Python might support markdown in the future
tooltip . insert_with_links_tagged ( autocomplete . documentation ) ;
else if ( autocomplete . kind = = " markdown " )
tooltip . insert_markdown ( autocomplete . documentation ) ;
else
tooltip . insert_code ( autocomplete . documentation , autocomplete . kind ) ;
}
}
}
} ;
} ;
} ;
} ;