@@ -1598,7 +1598,18 @@ angular
15981598 }
15991599 const selected = $scope . branches . filter ( ( b ) => b . name == $scope . source . branch ) ;
16001600 if ( selected . length > 0 ) {
1601- $scope . source . commit = selected [ 0 ] . commit ;
1601+ // Preserve the saved commit when editing with auto-update off:
1602+ // refreshing branches must not silently bump the pinned SHA to
1603+ // GitHub HEAD. Same intent as the source.branch watcher (#360),
1604+ // extended to cover the branches refresh path.
1605+ const keepSavedCommit =
1606+ $scope . isUpdate &&
1607+ ! $scope . options . update &&
1608+ $scope . _originalBranch === $scope . source . branch &&
1609+ ! ! $scope . source . commit ;
1610+ if ( ! keepSavedCommit ) {
1611+ $scope . source . commit = selected [ 0 ] . commit ;
1612+ }
16021613 $scope . readme = selected [ 0 ] . readme ;
16031614 await getReadme ( force ) ;
16041615 }
@@ -2258,7 +2269,7 @@ angular
22582269 return res . data ;
22592270 } catch ( err ) {
22602271 $scope . type = "error" ;
2261- $scope . content = err . data . error ;
2272+ $scope . content = ( err && err . data && err . data . error ) || "unknown_error" ;
22622273 $scope . files = [ ] ;
22632274 }
22642275 } ;
@@ -2567,6 +2578,10 @@ angular
25672578 for ( let i = 0 ; i < $scope . paths . length ; i ++ ) {
25682579 const path = i > 0 ? $scope . paths . slice ( 0 , i ) . join ( "/" ) : "" ;
25692580 await $scope . getFiles ( path ) ;
2581+ if ( $scope . type === "error" ) {
2582+ $scope . $apply ( ) ;
2583+ return ;
2584+ }
25702585 }
25712586 if ( $scope . files . length == 1 && $scope . files [ 0 ] . name == "" ) {
25722587 $scope . files = [ ] ;
0 commit comments