File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -786,7 +786,7 @@ extension SwiftLanguageService {
786
786
if let snapshot = try ? await latestSnapshot ( for: uri) {
787
787
let tree = await syntaxTreeManager. syntaxTree ( for: snapshot)
788
788
if let token = tree. token ( at: snapshot. absolutePosition ( of: position) ) {
789
- tokenRange = snapshot. absolutePositionRange ( of: token. position ..< token . endPosition )
789
+ tokenRange = snapshot. absolutePositionRange ( of: token. trimmedRange )
790
790
}
791
791
}
792
792
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ final class HoverTests: XCTestCase {
32
32
33
33
Details.
34
34
""" ,
35
- expectedRange: Position ( line: 3 , utf16index: 7 ) ..< Position ( line: 3 , utf16index: 9 )
35
+ expectedRange: Position ( line: 3 , utf16index: 7 ) ..< Position ( line: 3 , utf16index: 8 )
36
36
)
37
37
}
38
38
@@ -173,6 +173,24 @@ final class HoverTests: XCTestCase {
173
173
expectedRange: Position ( line: 3 , utf16index: 5 ) ..< Position ( line: 3 , utf16index: 13 )
174
174
)
175
175
}
176
+
177
+ func testTrivia( ) async throws {
178
+ try await assertHover (
179
+ """
180
+ func foo() {}
181
+ func bar() {
182
+ /*some comment*/1️⃣foo/*more comment*/()
183
+ }
184
+ """ ,
185
+ expectedContent: """
186
+ ```swift
187
+ func foo()
188
+ ```
189
+
190
+ """ ,
191
+ expectedRange: Position ( line: 2 , utf16index: 18 ) ..< Position ( line: 2 , utf16index: 21 )
192
+ )
193
+ }
176
194
}
177
195
178
196
private func assertHover(
You can’t perform that action at this time.
0 commit comments