Skip to content

Commit

Permalink
Fix highlighting when files tree has comments (#143)
Browse files Browse the repository at this point in the history
When someone leaves comments on a file, it puts an item in the files tree. These items do not have text spans like we're looking for, and so we get an error when trying to find the react property. That prevents highlighting from populating properly.
  • Loading branch information
m-akinc authored Mar 10, 2021
1 parent 18be314 commit d2c1059
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/azdo-pr-dashboard.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==

// @name AzDO Pull Request Improvements
// @version 2.53.0
// @version 2.53.1
// @author Alejandro Barreto (National Instruments)
// @description Adds sorting and categorization to the PR dashboard. Also adds minor improvements to the PR diff experience, such as a base update selector and per-file checkboxes.
// @license MIT
Expand Down Expand Up @@ -969,6 +969,11 @@
const text = fileRow.find('span.text-ellipsis');
const item = text.parent();

// For non-file/folder items in the tree (e.g. comments), we won't find a text span
if (text.length === 0) {
return;
}

/* eslint no-underscore-dangle: ["error", { "allow": ["_owner"] }] */
const pathAndChangeType = getPropertyThatStartsWith(text[0], '__reactInternalInstance$').memoizedProps.children._owner.stateNode.props.data.path;
const pathWithLeadingSlash = pathAndChangeType.replace(/ \[[a-z]+\]( renamed from .+)?$/, '');
Expand Down

0 comments on commit d2c1059

Please sign in to comment.