Skip to content

Commit 2e9ebf9

Browse files
committed
[SourceKit] Don’t set the code completion offset when doing completion-like cursor info
1 parent e777d37 commit 2e9ebf9

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %empty-directory(%t/split)
2+
// RUN: %{python} %utils/split_file.py -o %t/split %s
3+
// RUN: %empty-directory(%t/build)
4+
// RUN: %sourcekitd-test -req=cursor -pos=5:9 %t/split/MovieRow.swift -- %t/split/MovieRow.swift %t/split/Color.swift | %FileCheck %s
5+
6+
// BEGIN Color.swift
7+
8+
extension Invalid {}
9+
10+
// BEGIN MovieRow.swift
11+
12+
struct Bar {}
13+
14+
fileprivate let bar: Bar = {
15+
let bar = Bar()
16+
return bar
17+
}()
18+
19+
20+
// CHECK: source.lang.swift.decl.var.local (5:9-5:12)
21+
// CHECK-NEXT: bar
22+
// CHECK: RELATED BEGIN
23+
// CHECK-NEXT: <RelatedName usr="s:4main3bar33_F48676AE0C86F007C79C860E40EDA2D3LLAA3BarVvp">bar</RelatedName>
24+
// CHECK-NEXT: RELATED END

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,9 +1996,11 @@ void SwiftLangSupport::getCursorInfo(
19961996
[&](CancellableResult<CompletionLikeOperationParams> ParmsResult) {
19971997
ParmsResult.mapAsync<CursorInfoResults>(
19981998
[&](auto &Params, auto DeliverTransformed) {
1999+
// Set offset = ~0U to indicate that w did not insert a code
2000+
// completiom token into the source file.
19992001
getCompletionInstance()->cursorInfo(
20002002
Params.Invocation, Args, fileSystem,
2001-
Params.completionBuffer, Offset, Params.DiagC,
2003+
Params.completionBuffer, /*Offset=*/~0U, Params.DiagC,
20022004
Params.CancellationFlag, DeliverTransformed);
20032005
},
20042006
[&](auto Result) {

0 commit comments

Comments
 (0)