[tools] gopls/internal/golang: improve if-else folding range for vscode

6 views
Skip to first unread message

Xie Yuchen (Gerrit)

unread,
Sep 16, 2025, 7:24:25 AMSep 16
to goph...@pubsubhelper.golang.org, Alan Donovan, Hongxiang Jiang, Robert Findley, golang-co...@googlegroups.com
Attention needed from Alan Donovan, Hongxiang Jiang and Robert Findley

Xie Yuchen voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
  • Hongxiang Jiang
  • Robert Findley
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I77d524083a2be03f771b87cd591b8398b41a5469
Gerrit-Change-Number: 704096
Gerrit-PatchSet: 1
Gerrit-Owner: Xie Yuchen <xieyu...@gmail.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-Reviewer: Xie Yuchen <xieyu...@gmail.com>
Gerrit-Attention: Robert Findley <rfin...@google.com>
Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
Gerrit-Attention: Alan Donovan <adon...@google.com>
Gerrit-Comment-Date: Tue, 16 Sep 2025 11:24:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Robert Findley (Gerrit)

unread,
Sep 17, 2025, 6:08:24 PMSep 17
to Xie Yuchen, goph...@pubsubhelper.golang.org, Go LUCI, Alan Donovan, Hongxiang Jiang, golang-co...@googlegroups.com
Attention needed from Alan Donovan, Hongxiang Jiang and Xie Yuchen

Robert Findley added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Robert Findley . resolved

Thanks, Hongxiang and/or Alan can review (or add @mka...@google.com?)

Open in Gerrit

Related details

Attention is currently required from:
  • Alan Donovan
  • Hongxiang Jiang
  • Xie Yuchen
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: tools
    Gerrit-Branch: master
    Gerrit-Change-Id: I77d524083a2be03f771b87cd591b8398b41a5469
    Gerrit-Change-Number: 704096
    Gerrit-PatchSet: 1
    Gerrit-Owner: Xie Yuchen <xieyu...@gmail.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Reviewer: Xie Yuchen <xieyu...@gmail.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Xie Yuchen <xieyu...@gmail.com>
    Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Wed, 17 Sep 2025 22:08:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Sep 18, 2025, 11:01:23 AMSep 18
    to Xie Yuchen, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, Hongxiang Jiang, golang-co...@googlegroups.com
    Attention needed from Hongxiang Jiang and Xie Yuchen

    Alan Donovan voted and added 1 comment

    Votes added by Alan Donovan

    Hold+1

    1 comment

    File gopls/internal/golang/folding_range.go
    Line 69, Patchset 1 (Latest): // gopls now offers folding for each block stmt, in if-else statements,
    // each block will get its own folding range.
    // because go forces to put the close bracket with else like '} else {' or '} else if cond {'
    // the offered folding ranges have an overlapping place between the end of if block and the start of else block.
    // in vscode now, if the folding ranges have overlapping places, the later one will be ignored,
    // so users can only fold the if block and cannot fold the else block.
    //
    // The workaround adjusts the end position of a if block stmt from Rbrace to the end of the last statement in the block,
    // so folding ranges do not have overlapping places.
    // note that a single if block stmt isn't necessarily required this logic, but for simplicity,
    // we apply this logic to all block stmts inside an if statement.
    Alan Donovan . unresolved

    Can you describe the expected behavior of FoldingRange, from first principles, as if for the user manual? Unless I'm missing something, I feel like we ought to be able to specify the entire behavior in fewer words than this.

    Gopls seems to produce sensible information in the scenario of interest, so I suspect the problem is on the client side. Let's come to a consensus on the problem in the issue tracker before we attempt a fix.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Hongxiang Jiang
    • Xie Yuchen
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Holds
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: tools
      Gerrit-Branch: master
      Gerrit-Change-Id: I77d524083a2be03f771b87cd591b8398b41a5469
      Gerrit-Change-Number: 704096
      Gerrit-PatchSet: 1
      Gerrit-Owner: Xie Yuchen <xieyu...@gmail.com>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Reviewer: Xie Yuchen <xieyu...@gmail.com>
      Gerrit-CC: Robert Findley <rfin...@google.com>
      Gerrit-Attention: Xie Yuchen <xieyu...@gmail.com>
      Gerrit-Attention: Hongxiang Jiang <hxj...@golang.org>
      Gerrit-Comment-Date: Thu, 18 Sep 2025 15:01:18 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Xie Yuchen (Gerrit)

      unread,
      Nov 27, 2025, 6:25:41 AM (3 days ago) Nov 27
      to goph...@pubsubhelper.golang.org, Alan Donovan, Robert Findley, Go LUCI, Hongxiang Jiang, golang-co...@googlegroups.com

      Xie Yuchen abandoned this change

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Holds
      • requirement is not satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: abandon
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages