Merge pull request #2470 from overleaf/cmg-file-tree-highlight

Expand folder to show highlighted file in file tree

GitOrigin-RevId: 7fb9174fd71eb362655bcabf2f7884597aebee47
This commit is contained in:
nate stemen 2020-01-02 14:21:45 -05:00 committed by Copybot
parent 587c4ba129
commit 84f81d0eac
3 changed files with 29 additions and 6 deletions

View file

@ -17,7 +17,12 @@ define(['base', 'ide/file-tree/util/iconTypeFromName'], function(
App,
iconTypeFromName
) {
App.controller('FileTreeEntityController', function($scope, ide, $modal) {
App.controller('FileTreeEntityController', function(
$scope,
ide,
$modal,
$element
) {
$scope.select = function(e) {
if (e.ctrlKey || e.metaKey) {
e.stopPropagation()
@ -33,6 +38,17 @@ define(['base', 'ide/file-tree/util/iconTypeFromName'], function(
}
}
if ($scope.entity.type === 'doc') {
$scope.$watch('entity.selected', function(isSelected) {
if (isSelected) {
$scope.$emit('entity-file:selected', $scope.entity)
$scope.$applyAsync(function() {
$element[0].scrollIntoView()
})
}
})
}
$scope.draggableHelper = function() {
if (ide.fileTreeManager.multiSelectedCount() > 0) {
return $(

View file

@ -25,10 +25,16 @@ define(['base'], App =>
$scope.toggleExpanded = function() {
$scope.expanded = !$scope.expanded
return localStorage(
`folder.${$scope.entity.id}.expanded`,
$scope.expanded
)
$scope._storeCurrentStateInLocalStorage()
}
$scope.$on('entity-file:selected', function() {
$scope.expanded = true
$scope._storeCurrentStateInLocalStorage()
})
$scope._storeCurrentStateInLocalStorage = function() {
localStorage(`folder.${$scope.entity.id}.expanded`, $scope.expanded)
}
$scope.onDrop = function(events, ui) {

View file

@ -1017,7 +1017,8 @@ define([
}
ide.editorManager.openDoc(entity, {
gotoLine: line,
gotoColumn: column
gotoColumn: column,
forceReopen: true
})
}
})