@@ -87,8 +87,8 @@ function StringRep(props) {
8787 */
8888function getLinkifiedElements ( text , cropLimit , omitLinkHref , openLink ) {
8989 const halfLimit = Math . ceil ( ( cropLimit - ELLIPSIS . length ) / 2 ) ;
90- const startCropIndex = halfLimit ;
91- const endCropIndex = text . length - halfLimit ;
90+ const startCropIndex = cropLimit ? halfLimit : null ;
91+ const endCropIndex = cropLimit ? text . length - halfLimit : null ;
9292
9393 // As we walk through the tokens of the source string, we make sure to preserve
9494 // the original whitespace that separated the tokens.
@@ -151,13 +151,17 @@ function getLinkifiedElements(text, cropLimit, omitLinkHref, openLink) {
151151 * @param {String } text: The substring to crop.
152152 * @param {Integer } offset: The offset corresponding to the index at which the substring
153153 * is in the parent string.
154- * @param {Integer } startCropIndex: the index where the start of the crop should happen
155- * in the parent string
156- * @param {Integer } endCropIndex: the index where the end of the crop should happen
157- * in the parent string
154+ * @param {Integer|null } startCropIndex: the index where the start of the crop should
155+ * happen in the parent string.
156+ * @param {Integer|null } endCropIndex: the index where the end of the crop should happen
157+ * in the parent string
158158 * @returns {String|null } The cropped substring, or null if the text is completly cropped.
159159 */
160160function getCroppedString ( text , offset = 0 , startCropIndex , endCropIndex ) {
161+ if ( ! startCropIndex ) {
162+ return text ;
163+ }
164+
161165 const start = offset ;
162166 const end = offset + text . length ;
163167
0 commit comments