File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
crates/emmylua_ls/src/handlers Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -738,6 +738,17 @@ fn build_node_semantic_token(
738738 }
739739 return None ;
740740 }
741+ // 如果文档的开始是 #, 则需要将其渲染为注释而不是文档
742+ if let Some ( start_token) = description. tokens :: < LuaGeneralToken > ( ) . next ( ) {
743+ if start_token. get_text ( ) . starts_with ( '#' ) {
744+ builder. push_at_position (
745+ start_token. get_range ( ) . start ( ) ,
746+ 1 ,
747+ SemanticTokenType :: COMMENT ,
748+ None ,
749+ ) ;
750+ }
751+ }
741752
742753 let desc_range = description. get_range ( ) ;
743754 let document = semantic_model. get_document ( ) ;
Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ mod tests {
66 #[ gtest]
77 fn test_1 ( ) -> Result < ( ) > {
88 let mut ws = ProviderVirtualWorkspace :: new ( ) ;
9- ws. def (
9+ let _ = ws. check_semantic_token (
1010 r#"
1111 ---@class Cast1
12- ---@field get fun(self: self, a: number): Cast1?
12+ ---@field a string # test
1313 "# ,
14+ vec ! [ ] ,
1415 ) ;
1516 Ok ( ( ) )
1617 }
You can’t perform that action at this time.
0 commit comments