rfellows commented on code in PR #9888:
URL: https://github.com/apache/nifi/pull/9888#discussion_r2063562346
##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts:
##########
@@ -1478,19 +1478,27 @@ export class CanvasUtils {
let lineHeight = height;
for (const fullLine of lines) {
- const words: string[] = fullLine.split(/\s+/).reverse();
+ // Extract and preserve only the leading whitespace at the start
of the line
+ const trimmedLine = fullLine.trimStart();
+ const leadingWhitespace = fullLine.slice(0, fullLine.length -
trimmedLine.length);
+
+ // Split words normally, letting internal whitespace collapse
+ const words = trimmedLine.split(/\s+/).reverse();
+ if (words.length > 0) {
+ words[words.length - 1] = leadingWhitespace +
words[words.length - 1]; // Prepend leading space to the first word
+ }
Review Comment:
There is a minor performance hit here. It can make resizing of the label
feel jittery. It can be fixed by adding an additional condition here to only
update the array in this manor if there is actually whitespace to preserve:
```suggestion
if (leadingWhitespace.length > 0 && words.length > 0) {
words[words.length - 1] = leadingWhitespace +
words[words.length - 1]; // Prepend leading space to the first word
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]