import { Event , EventEmitter , Position , TextDocument } from 'vscode' ; export function isInputCompletion ( document , position ) { const text = document . getText ( ) ; let offset = document . offsetAt ( position ) ; do { offset -- ; } while ( /[^\\\s]/ . test ( text . charAt ( offset ) ) ) ; return text . charAt ( offset ) === '\\' ; } export class LowPassFilter < T > { constructor ( public delayms ) { } private emitter = new EventEmitter < T > ( ) ; on : Event < T > = this . emitter . event ; currentValue : T ; private scheduledTimer : NodeJS . Timer ; input ( t , now ? ) { this . currentValue = t ; if ( ! this . scheduledTimer ) { this . scheduledTimer = setTimeout ( ( ) => this . updateNow ( ) , this . delayms ) ; } if ( now ) { this . updateNow ( ) ; } } updateNow ( ) { if ( this . scheduledTimer ) { this . scheduledTimer = null ; this . emitter . fire ( this . currentValue ) ; } } }