diff --git a/exec/load/dd_lightbar_menu.js b/exec/load/dd_lightbar_menu.js
index 275dc38588640acd17b4424d9c1cd216f074b3b6..dae0171c9eb89f4e7e38cbcc8bcbe21fb97a9daf 100644
--- a/exec/load/dd_lightbar_menu.js
+++ b/exec/load/dd_lightbar_menu.js
@@ -3572,7 +3572,12 @@ function substrWithAttrCodes(pStr, pStartIdx, pLen)
 	// Find the actual start & end indexes, considering (not counting) attribute codes,
 	// and return the substring including any applicable attributes from the string
 	var actualStartIdx = findIdxConsideringAttrs(pStr, startIdx);
-	var actualEndIdx = findIdxConsideringAttrs(pStr, startIdx+len+1) + 1; // Initially tried just startIdx+len without the +1
+	var actualEndIdx = findIdxConsideringAttrs(pStr, startIdx+len+1);
+	// With the actual start & end indexes, make sure we'll get the string
+	// length desired; if not, adjust actualEndIdx;
+	var lenWithActualIndexes = actualEndIdx - actualStartIdx;
+	if (actualEndIdx-actualStartIdx < len)
+		actualEndIdx += len - lenWithActualIndexes;
 	return getAttrsBeforeStrIdx(pStr, actualStartIdx) + pStr.substring(actualStartIdx, actualEndIdx);
 }
 // Helper for substrWithAttrCodes(): Maps a 'visual' character index in a string to its
@@ -3926,4 +3931,4 @@ function logStackTrace(levels) {
     else {
         console.print(callstack.join("\r\n"));
     }
-}
\ No newline at end of file
+}