Example #1
0
 getFileMessageUpdates(filePath: NuclideUri): Observable<FileMessageUpdate> {
   const fileMessages = this._getFileMessages(filePath);
   const initialObservable = Observable.of({filePath, messages: fileMessages});
   return Observable.concat(
     initialObservable,
     this._fileChanges
       .filter(change => change.filePath === filePath),
   );
 }
 /**
  * A stream of all signature help triggers.
  */
 _signatureHelpTriggers(editor: atom$TextEditor): Observable<mixed> {
   return Observable.merge(
     // 1) Any keypresses that match a triggerCharacter.
     observableFromSubscribeFunction(cb =>
       editor.getBuffer().onDidChangeText(cb),
     )
       // The change events and cursor changes are often sequential.
       // We need to make sure we use the final cursor position.
       .let(fastDebounce(0))
       .filter(edit => {
         if (edit.changes.length !== 1) {
           return false;
         }
         const change = edit.changes[0];
         // Use the start of the current selection as the cursor position.
         // (Autocomplete often inserts a placeholder and puts the cursor at the end.)
         const cursorPosition = editor.getSelectedBufferRange().start;
         if (
           change.newText.length === 0 ||
           // Don't allow multi-line changes.
           change.newRange.start.row !== change.newRange.end.row ||
           // The change should cover the current cursor position.
           !change.newRange.containsPoint(cursorPosition)
         ) {
           return false;
         }
         // Use the character before the cursor as the 'trigger character'.
         const index = Math.max(
           0,
           cursorPosition.column - change.newRange.start.column - 1,
         );
         for (const provider of this._providerRegistry.getAllProvidersForEditor(
           editor,
         )) {
           if (provider.triggerCharacters != null) {
             if (provider.triggerCharacters.has(change.newText[index])) {
               return true;
             }
           }
         }
         return false;
       }),
     // 2) Explicit usage of the Atom command.
     this._commands.filter(e => e === editor),
   );
 }
Example #3
0
 constructor(props: Props) {
   super(props);
   this._disposable = new UniversalDisposable();
   this._hasher = new Hasher();
   this._renderedRecords = new Map();
   this.state = {
     width: 0,
     height: 0,
   };
   this._startIndex = 0;
   this._stopIndex = 0;
   this._refs = new Subject();
   this._disposable.add(
     this._refs
       .filter(Boolean)
       .switchMap(node => new ResizeObservable(nullThrows(node)).mapTo(node))
       .subscribe(node => {
         const {offsetHeight, offsetWidth} = nullThrows(node);
         this._handleResize(offsetHeight, offsetWidth);
       }),
   );
 }
Example #4
0
           query,
           line: match.row,
           column: match.column,
           context: match.line,
           displayPath: `./${nuclideUri
             .relative(projectRoot, match.file)
             .replace(/\\/g, '/')}`,
           resultType: 'FILE',
         };
         lastPath = match.file;
         return result;
       })
       .timeout(SEARCH_TIMEOUT)
       .catch(() => Observable.empty())
       .toArray()
       .takeUntil(directoriesObs.filter(dir => dir.getPath() === projectRoot))
       .toPromise()
       // toPromise yields undefined if it was interrupted.
       .then(result => result || [])
   );
 },
 getComponentForItem(_item: FileResult): React.Element<any> {
   const item = ((_item: any): CodeSearchFileResult);
   return (
     <div
       className={
         item.isFirstResultForPath
           ? 'code-search-provider-result-first-result-for-path'
           : null
       }>
       {item.isFirstResultForPath && (