Skip to content

Commit

Permalink
fix mix completions
Browse files Browse the repository at this point in the history
  • Loading branch information
reymondzzzz committed Nov 6, 2023
1 parent 6cb6bd5 commit f4fd298
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repositories {
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("2023.2.1")
type.set("IU") // Target IDE Platform
type.set("PC") // Target IDE Platform

plugins.set(listOf(
"Git4Idea",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class CompletionMode(
}

override fun onTextChange(event: DocumentEventExtra) {
if (completionInProgress) return
val fileName = getActiveFile(event.editor.document) ?: return
if (PrivacyService.getPrivacy(FileDocumentManager.getInstance().getFile(event.editor.document))
== Privacy.DISABLED && !InferenceGlobalContext.isSelfHosted) return
Expand Down Expand Up @@ -209,11 +210,12 @@ class CompletionMode(
if ((!completionInProgress) || (choice.delta.isEmpty() && !choice.finishReason.isNullOrEmpty())) {
return@streamedInferenceFetch
}
val completion: Completion = if (completionLayout?.lastCompletionData == null) {
val completion: Completion = if (completionLayout?.lastCompletionData == null ||
completionLayout?.lastCompletionData?.createdTs != prediction.created) {
Completion(request.body.inputs.sources.values.toList().first(),
offset = editorState.offset,
multiline = request.body.inputs.multiline,
createdTs = prediction.created.toLong(),
createdTs = prediction.created,
isFromCache = prediction.cached,
snippetTelemetryId = prediction.snippetTelemetryId
)
Expand All @@ -236,6 +238,7 @@ class CompletionMode(
requestFuture = it.get()
requestFuture.get()
logger.debug("Completion request finished")
completionInProgress = false
} catch (e: InterruptedException) {
handleInterruptedException(requestFuture, editorState.editor)
} catch (e: InterruptedIOException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CompletionState(
offset = startIndex,
// firstLineEndIndex = endIndex,
// endIndex = maxOf(endIndex, startIndex),
createdTs = System.currentTimeMillis(),
// createdTs = System.currentTimeMillis(),
// leftSymbolsToRemove = leftSymbolsToRemove,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AsyncCompletionLayout(
needToRender: Boolean,
animation: Boolean
): Future<*>? {
if (lastCompletionData != null && completionData.createdTs != lastCompletionData?.createdTs) return null
if (!isUpdating) return null
updateTask = scheduler.submit {
lastCompletionData = completionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data class Completion(
var completion: String = "",
val multiline: Boolean,
val offset: Int,
val createdTs: Long,
val createdTs: Double = -1.0,
val isFromCache: Boolean = false,
var snippetTelemetryId: Int? = null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName

data class SMCStreamingPeace(
val choices: List<StreamingChoice>,
val created: Float,
val created: Double,
val model: String,
@SerializedName("snippet_telemetry_id") val snippetTelemetryId: Int? = null,
val cached: Boolean = false
Expand Down

0 comments on commit f4fd298

Please sign in to comment.