Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,15 @@ export class CompletionContext {
let line = this.state.doc.lineAt(this.pos)
let start = Math.max(line.from, this.pos - 250)
let str = line.text.slice(start - line.from, this.pos - line.from)
let found = str.search(ensureAnchor(expr, false))
let found = -1
if (expr.global) {
let match
/// Use the last match in case of a global expression.
while ((match = expr.exec(str)) !== null) found = match.index
} else {
found = str.search(ensureAnchor(expr, false))
}

return found < 0 ? null : {from: start + found, to: this.pos, text: str.slice(found)}
}

Expand Down