<commit_before>angular.module(PKG.name + '.commons')
  .controller('myTabsCtrl', function($scope, $state) {
    $scope.tabs = $scope.tabsList().map(function (t){
      return {
        title: t,
        state: t.toLowerCase(),
        partial: $scope.tabsPartialPath + t.toLowerCase() + '.html'
      };
    });

    $scope.$watch('tabs.activeTab', function (newVal) {
      $state.go($state.includes('**.tab') ? $state.current : '.tab', {
        tab: $scope.tabs[newVal].state
      });
    });

    $scope.$on('$stateChangeSuccess', function (event, state) {
      var tab = $scope.tabs
        .map(function(t) {
          return t.state;
        })
        .indexOf($state.params.tab);

      if((tab < 0 || tab>=$scope.tabs.length)) {
        tab = 0;
      }
      $scope.tabs.activeTab = tab;
    });
    // FIXME: For some weird reason it doesn't default to the first tab.
    $scope.tabs.activeTab = 0;
  });<commit_msg>fix mytabs directive to load proper tab on load<commit_after>angular.module(PKG.name + '.commons')
  .controller('myTabsCtrl', function($scope, $state) {
    $scope.tabs = $scope.tabsList().map(function (t){
      return {
        title: t,
        state: t.toLowerCase(),
        partial: $scope.tabsPartialPath + t.toLowerCase() + '.html'
      };
    });

    $scope.$watch('tabs.activeTab', function (newVal) {
      $state.go($state.includes('**.tab') ? $state.current : '.tab', {
        tab: $scope.tabs[newVal].state
      });
    });

    function checkTabParam (event, state) {
      var tab = $scope.tabs
        .map(function(t) {
          return t.state;
        })
        .indexOf($state.params.tab);

      if((tab < 0 || tab>=$scope.tabs.length)) {
        tab = 0;
      }
      $scope.tabs.activeTab = tab;
    }

    $scope.$on('$stateChangeSuccess', checkTabParam);
    checkTabParam();
  });
{'fraction_non_alphanumeric': 0.18058568329718006, 'fraction_numerical': 0.0027114967462039045, 'mean_word_length': 2.3303249097472922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1203059', 'n_tokens_mistral': 599, 'n_tokens_neox': 593, 'n_words': 111}