-
Notifications
You must be signed in to change notification settings - Fork 578
fix: namespace completion to only use the short name #8350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Mathlib CI status (docs):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It's probably fine, but could you also double-check that completion still performs roughly the same with this change with import Mathlib
?
You can do so by rebasing your PR on nightly-with-mathlib
, creating a new project that depends on the PR testing branch, setting Lean4 > Trace: Server
in VS Code to 'messages', observing the timings in the 'Lean: Editor' output panel for completion requests that VS Code emits and comparing against master
. Single character identifier completion requests are usually the worst case.
a8a56b8
to
2460fe0
Compare
I ran the following test: Test code
import Mathlib
open Lean Elab Command Server Completion
def test (c : Syntax) : CommandElabM Unit := do
elabCommand c
let fileMap := FileMap.ofString c.getTrailing?.get!.str
let position := c.getTailPos?.get!
let pos := fileMap.toPosition position
let params : Lsp.CompletionParams := {
textDocument := {
uri := "file://Basic.lean"
}
position := {
line := pos.line
character := pos.column
}
}
for _ in [0:30] do
let trees ← getInfoTrees
for tree in trees do
let token ← RequestCancellationToken.new
let time ← IO.monoNanosNow
let hb ← IO.getNumHeartbeats
discard <| (find? params fileMap position c tree {}).run token
let hb' ← IO.getNumHeartbeats
let time' ← IO.monoNanosNow
Lean.logInfo m!"timing: {time' - time}, heartbeats: {hb' - hb}"
elab "#test_completion " c:command : command => test c
#test_completion #check A on both nightly-testing and this PR, the results:
|
Great! :-) |
This PR changes namespace completion to use the same algorithm as declaration identifier completion, which makes it use the short name (last name component) for completions instead of the full name, avoiding namespace duplications.
Closes #5654