Skip to content

Commit 7ffbe11

Browse files
authored
Only include user typing in typing speed computation (#260339)
1 parent 423e5da commit 7ffbe11

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/vs/editor/contrib/inlineCompletions/browser/model/typingSpeed.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ export class TypingInterval extends Disposable {
6060

6161
private _updateTypingSpeed(change: IModelContentChangedEvent): void {
6262
const now = Date.now();
63-
const characterCount = this._calculateEffectiveCharacterCount(change);
63+
64+
if (!this._isUserTyping(change)) {
65+
this._finalizeCurrentSession();
66+
return;
67+
}
6468

6569
// If too much time has passed since last change, start a new session
6670
if (this._currentSession && (now - this._lastChangeTime) > TypingInterval.MAX_SESSION_GAP_MS) {
@@ -78,24 +82,12 @@ export class TypingInterval extends Disposable {
7882

7983
// Update current session
8084
this._currentSession.endTime = now;
81-
this._currentSession.characterCount += characterCount;
85+
this._currentSession.characterCount += this._getActualCharacterCount(change);
8286

8387
this._lastChangeTime = now;
8488
this._cacheInvalidated = true;
8589
}
8690

87-
private _calculateEffectiveCharacterCount(change: IModelContentChangedEvent): number {
88-
const actualCharCount = this._getActualCharacterCount(change);
89-
90-
// If this is actual user typing, count all characters
91-
if (this._isUserTyping(change)) {
92-
return actualCharCount;
93-
}
94-
95-
// For all other actions (paste, suggestions, etc.), count as 1 regardless of size
96-
return actualCharCount > 0 ? 1 : 0;
97-
}
98-
9991
private _getActualCharacterCount(change: IModelContentChangedEvent): number {
10092
let totalChars = 0;
10193
for (const c of change.changes) {
@@ -108,7 +100,7 @@ export class TypingInterval extends Disposable {
108100
private _isUserTyping(change: IModelContentChangedEvent): boolean {
109101
// If no detailed reasons, assume user typing
110102
if (!change.detailedReasons || change.detailedReasons.length === 0) {
111-
return true;
103+
return false;
112104
}
113105

114106
// Check if any of the reasons indicate actual user typing

0 commit comments

Comments
 (0)