Skip to content
Snippets Groups Projects
Commit 2d43ccaf authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_lightbar_menu_substrWithAttrCodes_len_fix' into 'master'

dd_lightbar_menu.js: Length off-by-1 fix in substrWithAttrCodes()

See merge request !354
parents c9c260f0 10d8683f
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment