@@ -34,17 +34,18 @@ func TestHover(t *testing.T) {
3434 clientJSONConn , testURI := setupLSPServer (t , testProtoPath )
3535
3636 tests := []struct {
37- name string
38- line uint32
39- character uint32
40- expectedContains string
41- expectNoHover bool
37+ name string
38+ line uint32
39+ character uint32
40+ expectedContains string
41+ expectedNotContains string
42+ expectNoHover bool
4243 }{
4344 {
4445 name : "hover_on_user_message" ,
45- line : 7 , // Line with "message User {"
46- character : 8 , // On the word "User"
47- expectedContains : "User represents a user in the system" ,
46+ line : 7 , // Line with "message User {"
47+ character : 8 , // On the word "User"
48+ expectedContains : "system. \n This" , // Ensure newline between comment lines
4849 },
4950 {
5051 name : "hover_on_id_field" ,
@@ -76,6 +77,16 @@ func TestHover(t *testing.T) {
7677 character : 6 , // On "GetUser"
7778 expectedContains : "GetUser retrieves a user by their ID" ,
7879 },
80+ {
81+ name : "hover_on_deprecated_option" ,
82+ line : 37 , // Line with "option deprecated = true;"
83+ character : 11 , // On "deprecated"
84+ // We don't want the hover info to include the floating comment that is separated by newlines
85+ // from the comment above the option.
86+ // Ref: https://buf.build/protocolbuffers/wellknowntypes/file/main:google/protobuf/descriptor.proto#L946
87+ expectedNotContains : "Buffers." , // From last line of the previous floating comment.
88+ expectedContains : "Is this method deprecated?" ,
89+ },
7990 {
8091 name : "hover_on_status_type_reference" ,
8192 line : 15 , // Line with "Status status = 3;"
@@ -84,7 +95,7 @@ func TestHover(t *testing.T) {
8495 },
8596 {
8697 name : "hover_on_user_type_reference" ,
87- line : 45 , // Line with "User user = 1;"
98+ line : 50 , // Line with "User user = 1;"
8899 character : 2 , // On "User" type
89100 expectedContains : "User represents a user in the system" ,
90101 },
@@ -145,10 +156,17 @@ func TestHover(t *testing.T) {
145156
146157 if tt .expectNoHover {
147158 assert .Nil (t , hover , "expected no hover information" )
148- } else if tt .expectedContains != "" {
149- require .NotNil (t , hover , "expected hover to be non-nil" )
150- assert .Equal (t , protocol .Markdown , hover .Contents .Kind )
151- assert .Contains (t , hover .Contents .Value , tt .expectedContains )
159+ } else {
160+ if tt .expectedContains != "" {
161+ require .NotNil (t , hover , "expected hover to be non-nil" )
162+ assert .Equal (t , protocol .Markdown , hover .Contents .Kind )
163+ assert .Contains (t , hover .Contents .Value , tt .expectedContains )
164+ }
165+ if tt .expectedNotContains != "" {
166+ require .NotNil (t , hover , "expected hover to be non-nil" )
167+ assert .Equal (t , protocol .Markdown , hover .Contents .Kind )
168+ assert .NotContains (t , hover .Contents .Value , tt .expectedNotContains )
169+ }
152170 }
153171 })
154172 }
0 commit comments