fix: playground segments range error. (#242)

improve-workflow
Zhiming Ma 2023-06-15 23:25:41 +08:00 committed by GitHub
parent 9abf1a7521
commit 008ad75e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -100,19 +100,19 @@ class CompletionProvider {
freeInlineCompletions() {}
getSegments(document, position) {
const firstLine = Math.max(position.lineNumber - 120, 0)
const firstLine = Math.max(position.lineNumber - 120, 1)
const prefixRange = new this.monaco.Range(
firstLine,
0,
1,
position.lineNumber,
position.column
)
const lastLine = Math.min(position.lineNumber + 120, document.getLineCount() - 1)
const lastLine = Math.min(position.lineNumber + 120, document.getLineCount())
const suffixRange = new this.monaco.Range(
position.lineNumber,
position.column,
lastLine,
document.getLineLength(lastLine)
document.getLineLength(lastLine) + 1
)
return {
prefix: document.getValueInRange(prefixRange),