fix: widget messages

This commit is contained in:
Wojciech Nawrocki 2021-10-16 22:03:45 -04:00 committed by Sebastian Ullrich
parent b1bd3fc304
commit e843fb7ca5
3 changed files with 15 additions and 9 deletions

View file

@ -68,6 +68,8 @@ builtin_initialize
FileWorker.getInteractiveTermGoal
structure GetInteractiveDiagnosticsParams where
/-- Return diagnostics for these lines only if present,
otherwise return all diagnostics. -/
lineRange? : Option Lsp.LineRange
deriving Inhabited, FromJson, ToJson
@ -76,12 +78,15 @@ def getInteractiveDiagnostics (params : GetInteractiveDiagnosticsParams) : Reque
let doc ← readDoc
let rangeEnd ← params.lineRange?.map fun range =>
doc.meta.text.lspPosToUtf8Pos ⟨range.«end», 0⟩
withWaitFindSnap doc (fun snap => rangeEnd.all (· ≤ snap.endPos)) #[]
fun snap => snap.interactiveDiags.toArray.filter fun diag =>
params.lineRange?.all fun ⟨s, e⟩ =>
-- does [s,e) intersect [diag.fullRange.start.line,diag.fullRange.end.line)?
s ≤ diag.fullRange.start.line ∧ diag.fullRange.start.line < e
diag.fullRange.start.line ≤ s ∧ s < diag.fullRange.end.line
let t ← doc.cmdSnaps.waitAll fun snap => rangeEnd.all (snap.beginPos < ·)
t.map fun (snaps, _) =>
let diags? := snaps.getLast?.map fun snap =>
snap.interactiveDiags.toArray.filter fun diag =>
params.lineRange?.all fun ⟨s, e⟩ =>
-- does [s,e) intersect [diag.fullRange.start.line,diag.fullRange.end.line)?
s ≤ diag.fullRange.start.line ∧ diag.fullRange.start.line < e
diag.fullRange.start.line ≤ s ∧ s < diag.fullRange.end.line
diags?.getD #[]
builtin_initialize
registerRpcCallHandler

View file

@ -95,9 +95,9 @@ def bindTask (t : Task α) (f : α → RequestM (RequestTask β)) : RequestM (Re
| Except.error e => throwThe RequestError e
| Except.ok v => v
/-- Create a task which waits for a snapshot matching `p`, handles various errors,
and if a matching snapshot was found executes `x` with it. If not found, the task
executes `notFoundX`. -/
/-- Create a task which waits for the first snapshot matching `p`, handles various errors,
and if a matching snapshot was found executes `x` with it. If not found, the task executes
`notFoundX`. -/
def withWaitFindSnap (doc : EditableDocument) (p : Snapshot → Bool)
(notFoundX : RequestM β)
(x : Snapshot → RequestM β)

View file

@ -78,6 +78,7 @@ private def formatWithOpts (e : Expr) (optsPerPos : Delaborator.OptionsPerPos)
let currNamespace ← getCurrNamespace
let openDecls ← getOpenDecls
let opts ← getOptions
let e ← Meta.instantiateMVars e
let (stx, infos) ← PrettyPrinter.delabCore currNamespace openDecls e optsPerPos
let stx := sanitizeSyntax stx |>.run' { options := opts }
let stx ← PrettyPrinter.parenthesizeTerm stx