@@ -147,7 +147,8 @@ private static void InitializeAsync()
147147 pulseProcessor_client = new HttpClient ( pulseProcessor_httpClientHandler ) ;
148148 timer . Interval = pulseFrequency ;
149149 timer . Elapsed += ProcessPulses ;
150- timer . Start ( ) ;
150+ timer . AutoReset = false ; // fire only once after it's started
151+ //timer.Start();
151152
152153 if ( Stats )
153154 {
@@ -338,7 +339,7 @@ public static void OnNotification(ScNotification notification)
338339 if ( notification . Header . Code == ( uint ) SciMsg . SCN_CHARADDED ) // our best bet
339340 {
340341 if ( Debug ) Logger . Debug ( "[notification] SCN_CHARADDED" ) ;
341- HandleActicity ( ) ;
342+ HandleActivity ( ) ;
342343 if ( Debug ) Logger . Debug ( "SCN_CHARADDED - File: " + GetCurrentFile ( ) + ", char: " + ( char ) notification . character + " (" + notification . character + "), lang: " + GetCurrentLanguage ( ) ) ;
343344 }
344345
@@ -350,7 +351,7 @@ public static void OnNotification(ScNotification notification)
350351 // It doesn't trigger on file close either, unlike on open with SC_MOD_INSERTTEXT, so we only use this, and SCN_CHARADDED for inserts
351352 // It will skip Ctrl+V if it wasn't pasted on some existing text, but never mind, it is still counting the most we want
352353 // And we would not like it to count random file opens or other actions in
353- HandleActicity ( ) ;
354+ HandleActivity ( ) ;
354355 if ( Debug ) Logger . Debug ( "SC_PERFORMED_USER & SC_MOD_DELETETEXT - File: " + GetCurrentFile ( ) + ", char: " + notification . character + ", flags: " + notification . ModificationType . ToString ( "X" ) ) ;
355356 }
356357
@@ -379,7 +380,7 @@ public static void UpdateStatusbar()
379380 _lastStatusBarDocTypeText = newStatusBarDocTypeText ;
380381 }
381382
382- public static void HandleActicity ( )
383+ public static void HandleActivity ( )
383384 {
384385 if ( ! nppStarted ) return ;
385386
@@ -394,6 +395,8 @@ public static void HandleActicity()
394395 string json = jsonSerializer.Serialize(currentPulse);
395396 Logger.Debug(json);*/
396397 _lastActivity = DateTime . Now ;
398+
399+ timer . Start ( ) ;
397400 }
398401
399402 private static void FlushCurrentPulseIfNeeded ( )
@@ -412,8 +415,14 @@ private static void ProcessPulses(object sender, ElapsedEventArgs e)
412415 {
413416 try
414417 {
415- if ( pulseQueue != null && ( ( currentPulse != null && ! currentPulse . isEmpty ( ) ) || ! pulseQueue . IsEmpty ) && EnoughTimePassed ( DateTime . Now ) )
418+ if ( pulseQueue != null && ( ( currentPulse != null && ! currentPulse . isEmpty ( ) ) || ! pulseQueue . IsEmpty ) )
416419 {
420+ if ( ! EnoughTimePassed ( DateTime . Now ) )
421+ {
422+ timer . Start ( ) ;
423+ return ;
424+ }
425+
417426 // if current pulse is not empty, add it to the queue now
418427 FlushCurrentPulseIfNeeded ( ) ;
419428
@@ -962,7 +971,8 @@ internal static void PluginCleanUp()
962971 if ( ! result . isEmpty ( ) )
963972 {
964973 string json = jsonSerializer . Serialize ( result ) ;
965- Logger . Debug ( "Unsaved pulse: " + json ) ;
974+ Logger . Info ( "Unsaved pulse: " + json ) ;
975+ // TODO: dump them to file and restore
966976 }
967977 }
968978
0 commit comments