rfellows commented on code in PR #9888:
URL: https://github.com/apache/nifi/pull/9888#discussion_r2060209563


##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/pages/flow-designer/service/canvas-utils.service.ts:
##########
@@ -1478,11 +1478,16 @@ export class CanvasUtils {
         let lineHeight = height;
 
         for (const fullLine of lines) {
-            const words: string[] = fullLine.split(/\s+/).reverse();
+            // Preserve leading spaces per word
+            const words: string[] = fullLine.match(/(\s*\S+)/g)?.reverse() || 
[];

Review Comment:
   This might be too aggressive. Now, all leading whitespace is considered part 
of the subsequent word treating space, tab, and line breaks as regular 
characters and not as an opportunity to wrap text at those points. Prior to 
this change, whitespace was treated similar to how it renders in html, multiple 
consecutive spaces would render as a single one and would allow wrapping there. 
Now, if you have many spaces together between words the leading spaces before 
the word are now bound together and will not allow wrapping in the middle of 
the spaces, treating a string like "          hello" as 15 characters rather 
than 5.
   
   Consider the string `Hello                                           World`
   Before change:
   <img width="314" alt="Screenshot 2025-04-25 at 09 06 20" 
src="https://github.com/user-attachments/assets/1dcbc102-2e8b-49ba-88f2-884ee28eb3e3";
 />
   
   After change:
   <img width="276" alt="Screenshot 2025-04-25 at 09 06 51" 
src="https://github.com/user-attachments/assets/31873fd1-54ff-4ccf-bed8-0eca223b2a86";
 />
   
   I think the best solution would be to only preserve whitespace at the 
beginning of a line(start of string or following line break) and let whitespace 
collapse elsewhere like it did before.
   
   Another consequence of the current solution is that since the leading space 
is preserved, it can make lines look indented when they do wrap to the next 
line:
   <img width="556" alt="Screenshot 2025-04-25 at 09 02 54" 
src="https://github.com/user-attachments/assets/b6e07a73-2e67-41c0-900a-fb0504f3fdc9";
 />
   
   
   



-- 
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]

Reply via email to