@@ -64,10 +64,11 @@ local function asStringView(source, literal)
6464 if config .get (guide .getUri (source ), ' Lua.hover.viewString' )
6565 and (source [2 ] == ' "' or source [2 ] == " '" )
6666 and rawLen > # literal then
67- local view = literal
67+ local view = util . escapeInvalidUtf8 ( literal )
6868 local max = config .get (guide .getUri (source ), ' Lua.hover.viewStringMax' )
6969 if # view > max then
70- view = view :sub (1 , max ) .. ' ...'
70+ local nextCharacter = utf8.offset (view , 0 , max + 1 )
71+ view = view :sub (1 , nextCharacter - 1 ) .. ' ...'
7172 end
7273 local md = markdown ()
7374 md :add (' txt' , view )
@@ -486,7 +487,7 @@ local function tryDocEnum(source)
486487 if not key then
487488 goto CONTINUE
488489 end
489- keys [# keys + 1 ] = ( ' %q ' ): format (key )
490+ keys [# keys + 1 ] = util . viewLiteral (key )
490491 :: CONTINUE::
491492 end
492493 end
@@ -507,7 +508,8 @@ local function tryDocEnum(source)
507508 end
508509 if field .value .type == ' integer'
509510 or field .value .type == ' string' then
510- md :add (' lua' , (' %s: %s = %q,' ):format (key , field .value .type , field .value [1 ]))
511+ local value = util .viewLiteral (field .value [1 ])
512+ md :add (' lua' , (' %s: %s = %s,' ):format (key , field .value .type , value ))
511513 end
512514 if field .value .type == ' binary'
513515 or field .value .type == ' unary' then
0 commit comments