<commit_before>
module Source {

  export function SourceController($scope, $location, $routeParams, workspace:Workspace, fileExtensionTypeRegistry, jolokia) {

    $scope.pageId = Wiki.pageId($routeParams, $location);
    $scope.format = Wiki.fileFormat($scope.pageId, fileExtensionTypeRegistry);
    var lineNumber = $location.search()["line"] || 1;

    console.log("Source format is " + $scope.format + " line " + lineNumber);

    $scope.breadcrumbs = [];

    // TODO load breadcrumbs
    // $scope.breadcrumbs.push({href: "#" + loc, name: name});

    updateView();

    var options = {
      readOnly: true,
      mode: {
        lineNumbers: true,
        cursor: lineNumber,
        name: $scope.format
      },
      // Quick hack to get the codeMirror instance.
      onChange: function(codeMirror) {
        if (codeMirror) {
          $scope.codeMirror = codeMirror;
          lineNumber -= 1;
          var lineText = codeMirror.getLine(lineNumber);
          var endChar = (lineText) ? lineText.length : 1000;
          var start = {line: lineNumber, ch: 0};
          var end = {line: lineNumber, ch: endChar};
          codeMirror.scrollIntoView(start);
          codeMirror.setCursor(start);
          codeMirror.setSelection(start, end);
          codeMirror.refresh();
          codeMirror.focus();
        }
      }
    };
    $scope.codeMirrorOptions = CodeEditor.createEditorSettings(options);

    // TODO how to set the line number easily?

    $scope.$watch('workspace.tree', function () {
      if (!$scope.git && Git.getGitMBean(workspace)) {
        // lets do this asynchronously to avoid Error: $digest already in progress
        //console.log("Reloading the view as we now seem to have a git mbean!");
        setTimeout(updateView, 50);
      }
    });
<commit_msg>only update the focussed line on startup<commit_after>
module Source {

  export function SourceController($scope, $location, $routeParams, workspace:Workspace, fileExtensionTypeRegistry, jolokia) {

    $scope.pageId = Wiki.pageId($routeParams, $location);
    $scope.format = Wiki.fileFormat($scope.pageId, fileExtensionTypeRegistry);
    var lineNumber = $location.search()["line"] || 1;

    console.log("Source format is " + $scope.format + " line " + lineNumber);

    $scope.breadcrumbs = [];

    // TODO load breadcrumbs
    // $scope.breadcrumbs.push({href: "#" + loc, name: name});

    updateView();

    var options = {
      readOnly: true,
      mode: {
        lineNumbers: true,
        cursor: lineNumber,
        name: $scope.format
      },
      // Quick hack to get the codeMirror instance.
      onChange: function(codeMirror) {
        if (codeMirror) {
          if (!$scope.codeMirror) {
            lineNumber -= 1;
            var lineText = codeMirror.getLine(lineNumber);
            var endChar = (lineText) ? lineText.length : 1000;
            var start = {line: lineNumber, ch: 0};
            var end = {line: lineNumber, ch: endChar};
            codeMirror.scrollIntoView(start);
            codeMirror.setCursor(start);
            codeMirror.setSelection(start, end);
            codeMirror.refresh();
            codeMirror.focus();
          }
          $scope.codeMirror = codeMirror;
        }
      }
    };
    $scope.codeMirrorOptions = CodeEditor.createEditorSettings(options);

    // TODO how to set the line number easily?

    $scope.$watch('workspace.tree', function () {
      if (!$scope.git && Git.getGitMBean(workspace)) {
        // lets do this asynchronously to avoid Error: $digest already in progress
        //console.log("Reloading the view as we now seem to have a git mbean!");
        setTimeout(updateView, 50);
      }
    });

{'fraction_non_alphanumeric': 0.12368064952638701, 'fraction_numerical': 0.004871447902571042, 'mean_word_length': 2.493383742911153, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5005957', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1035, 'n_words': 264}