Skip to content

Commit

Permalink
Fix an issue in StreamLanguage indentation
Browse files Browse the repository at this point in the history
FIX: Fix an issue where indentation for a stream language would fail to work
when the parse covered only part of the document, far from the start.

Closes codemirror/dev#1483
  • Loading branch information
marijnh committed Nov 30, 2024
1 parent 17e4215 commit e3ccab2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/stream-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class StreamLanguage<State> extends Language {
}
let start = findState(this, cx.node.tree!, 0, cx.node.from, from ?? cx.pos), statePos, state
if (start) { state = start.state; statePos = start.pos + 1 }
else { state = this.streamParser.startState(cx.unit) ; statePos = 0 }
else { state = this.streamParser.startState(cx.unit) ; statePos = cx.node.from }
if (cx.pos - statePos > C.MaxIndentScanDist) return null
while (statePos < cx.pos) {
let line = cx.state.doc.lineAt(statePos), end = Math.min(cx.pos, line.to)
Expand Down

0 comments on commit e3ccab2

Please sign in to comment.