leanprover / vscode-lean4

Visual Studio Code extension for the Lean 4 proof assistant
Apache License 2.0
155 stars 47 forks source link

Incorrect highlighting if deprecation message contains `]` character #515

Open TwoFX opened 1 month ago

TwoFX commented 1 month ago

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The following code produces incorrect highlighting in VS Code in recent (post-#3968) Lean releases:

@[deprecated Array.get? "Use a[i]? or a.get? i instead"]
def Array.atIndex? (a : Array α) (i : Nat) : Option α :=
  a.get? i

image

The web editor at live.lean-lang.org seems to be unaffected by this issue.

An interesting variant of this is

@[deprecated Array.get? "Use `a[i]?` or `a.get? i` instead", inherit_doc Array.get?]

where the highlighting is only broken until the end of the attribute.

Steps to Reproduce

  1. Create a new Lean project on a recent nightly and paste in the above code

Expected behavior: Highlighting should work as usual

Actual behavior: Highlighting gets confused by the ] character in the deprecation message.

Versions

4.11.0-nightly-2024-08-05
Linux markus-z16 6.9.12-200.fc40.x86_64 leanprover/lean4#1 SMP PREEMPT_DYNAMIC Sat Jul 27 15:56:15 UTC 2024 x86_64 GNU/Linux
vscode-lean4 v.0.0.176 in VS Code 1.92.0

Impact

Add :+1: to issues you consider important. If others are impacted by this issue, please ask them to add :+1: to it.

eric-wieser commented 1 month ago

I think this was fixed already in lean3, in https://github.com/leanprover/vscode-lean/pull/265