Commit 61da5cd
internal/astutil: return enclosing node when selection contains no nodes
Previously, if a selection range did not wholly enclose any syntax nodes
(e.g., point selections or ranges covering only whitespace), Select
returned an error with all noCursor return values.
Select now returns the valid enclosing cursor alongside the error in
these cases, while keeping start and end as noCursor.
This allows callers to inspect the surrounding syntax tree even when the
selection does not map to specific sub-nodes.
Change-Id: I623cd5bc1b4173970ad1dc3e7baae79aa74cc5de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/730320
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>1 parent 454a5c0 commit 61da5cd
File tree
2 files changed
+10
-5
lines changed- gopls/internal/golang
- internal/astutil
2 files changed
+10
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 34 | + | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
181 | 184 | | |
182 | 185 | | |
183 | 186 | | |
| |||
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
218 | 226 | | |
219 | 227 | | |
220 | 228 | | |
| |||
0 commit comments