<commit_before>(function (angular) {
  
  'use strict';
  
  angular.module('bebop.search')
  
  .directive('searchBar', ['$timeout', '$location', 'searchService', 
    
    function ($timeout, $location, searchService) {
    
    return {
      restrict: 'E',
      replace: true,
      templateUrl: 'modules/search/views/searchbar.html',
      link: function (scope, element, attrs) {
        
        var $t;
        
        function doSearch() {
          searchService.search(scope.search, 'room').then(function($results) {
            scope.searching = false;
            if ($results) {
              scope.results = $results.hits; 
            }
          }).catch(function (error) {
            console.error(error);
            scope.searching = false;
          });
        }
        
        scope.$watch('search', function (value, lastValue) {
          
          // If there's a previous timeout, cancel it
          if ($t) $timeout.cancel($t);
          
          // Don't preceed unless there is a search, it's new, and it's at least 3 chars
          if (!value || value === lastValue || value.length <= 2) {
            scope.searching = false;
            scope.results = [];
            return;
          }
          
          scope.searching = true;
          
          // Perform the search
          $t = $timeout(doSearch, 500);
          <commit_msg>Better logic for empty search results<commit_after>(function (angular) {
  
  'use strict';
  
  angular.module('bebop.search')
  
  .directive('searchBar', ['$timeout', '$location', 'searchService', 
    
    function ($timeout, $location, searchService) {
    
    return {
      restrict: 'E',
      replace: true,
      templateUrl: 'modules/search/views/searchbar.html',
      link: function (scope, element, attrs) {
        
        var $t;
        
        function doSearch() {
          searchService.search(scope.search, 'room').then(function($results) {
            scope.searching = false;
            if ($results) {
              scope.results = $results.hits || []; 
            }
          }).catch(function (error) {
            console.error(error);
            scope.searching = false;
          });
        }
        
        scope.$watch('search', function (value, lastValue) {
          
          // If there's a previous timeout, cancel it
          if ($t) $timeout.cancel($t);
          
          // Don't preceed unless there is a search, it's new, and it's at least 3 chars
          if (!value || value === lastValue || value.length <= 2) {
            scope.searching = false;
            scope.results = [];
            return;
          }
          
          scope.searching = true;
          
          // Perform the search
          $t = $timeout(doSearch, 500);
          
{'fraction_non_alphanumeric': 0.12750716332378223, 'fraction_numerical': 0.0035816618911174787, 'mean_word_length': 1.5765682656826567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4812503', 'n_tokens_mistral': 772, 'n_tokens_neox': 750, 'n_words': 183}