@@ -60,7 +60,11 @@ export class TypingInterval extends Disposable {
60
60
61
61
private _updateTypingSpeed ( change : IModelContentChangedEvent ) : void {
62
62
const now = Date . now ( ) ;
63
- const characterCount = this . _calculateEffectiveCharacterCount ( change ) ;
63
+
64
+ if ( ! this . _isUserTyping ( change ) ) {
65
+ this . _finalizeCurrentSession ( ) ;
66
+ return ;
67
+ }
64
68
65
69
// If too much time has passed since last change, start a new session
66
70
if ( this . _currentSession && ( now - this . _lastChangeTime ) > TypingInterval . MAX_SESSION_GAP_MS ) {
@@ -78,24 +82,12 @@ export class TypingInterval extends Disposable {
78
82
79
83
// Update current session
80
84
this . _currentSession . endTime = now ;
81
- this . _currentSession . characterCount += characterCount ;
85
+ this . _currentSession . characterCount += this . _getActualCharacterCount ( change ) ;
82
86
83
87
this . _lastChangeTime = now ;
84
88
this . _cacheInvalidated = true ;
85
89
}
86
90
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
-
99
91
private _getActualCharacterCount ( change : IModelContentChangedEvent ) : number {
100
92
let totalChars = 0 ;
101
93
for ( const c of change . changes ) {
@@ -108,7 +100,7 @@ export class TypingInterval extends Disposable {
108
100
private _isUserTyping ( change : IModelContentChangedEvent ) : boolean {
109
101
// If no detailed reasons, assume user typing
110
102
if ( ! change . detailedReasons || change . detailedReasons . length === 0 ) {
111
- return true ;
103
+ return false ;
112
104
}
113
105
114
106
// Check if any of the reasons indicate actual user typing
0 commit comments