🎉 Node-RED 1.1.0-beta.3 released

Odd issue with the file in node. A couple of flile in nodes have wrapped to a second line and won't go back even if I edit the file name:

[{"id":"57f9f3a.e32620c","type":"file in","z":"d480ffdb.73b02","name":"","filename":"/home/pi//node/nrlive/.data/.config.json","format":"utf8","chunk":false,"sendError":false,"x":450,"y":160,"wires":[["d1d4a711.9a25d8"]]},{"id":"d1d4a711.9a25d8","type":"json","z":"d480ffdb.73b02","name":"","pretty":false,"x":670,"y":160,"wires":[["3e2d0b11.b34c34"]]},{"id":"e1bdf411.316238","type":"change","z":"d480ffdb.73b02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t    $each(payload.nodes,function($v, $k) {\t        {\t            \"name\": $k,\t            \"nodes\": $keys($v.nodes)\t        }\t    }); \t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":260,"wires":[["1a0235f0.8c486a"]]},{"id":"1a0235f0.8c486a","type":"debug","z":"d480ffdb.73b02","name":"","active":true,"console":"false","complete":"false","x":1030,"y":260,"wires":[]},{"id":"b6c696f6.b0bbe8","type":"inject","z":"d480ffdb.73b02","name":"","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":220,"y":160,"wires":[["57f9f3a.e32620c","62b31849.ce3328"]]},{"id":"bae74244.be8fa","type":"comment","z":"d480ffdb.73b02","name":"How Many Node modules in my configuration?","info":"","x":330,"y":120,"wires":[]},{"id":"62b31849.ce3328","type":"file in","z":"d480ffdb.73b02","name":"","filename":"C:\\src\\nr\\data\\.config.json","format":"utf8","chunk":false,"sendError":false,"x":410,"y":200,"wires":[["d1d4a711.9a25d8"]]},{"id":"3e2d0b11.b34c34","type":"change","z":"d480ffdb.73b02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.nodes {\t    \"TOTAL\": $count($keys($)),\t    \"node_modules\": ($.nodes)\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":160,"wires":[["debfd61c.eef3b8"]]},{"id":"debfd61c.eef3b8","type":"debug","z":"d480ffdb.73b02","name":"","active":true,"console":"false","complete":"false","x":1030,"y":160,"wires":[]},{"id":"388ada2d.cb9c86","type":"change","z":"d480ffdb.73b02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$each(payload.nodes,function($v, $k) {\t    $map($keys($v.nodes),function($val,$i,$arr) {\t    \t$val & \" : \" & $k\t    })\t})\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":300,"wires":[["6a0fed45.9ca7e4"]]},{"id":"6a0fed45.9ca7e4","type":"debug","z":"d480ffdb.73b02","name":"","active":true,"console":"false","complete":"false","x":1030,"y":300,"wires":[]},{"id":"7c2f2610.dfcd68","type":"change","z":"d480ffdb.73b02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$map(payload.nodes.*.nodes, function($val,$key){\t    $each($val, function($v, $k) {\t    \t$k & \" : \" & $v.module\t    })\t})","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":340,"wires":[["a1ffbab3.31f078"]]},{"id":"5b712eaa.8e40b","type":"change","z":"d480ffdb.73b02","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sort(payload.nodes.*.nodes.(\t    $each($, function($v, $k) {\t    \t$k & \" : \" & $v.module\t    })\t))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":380,"wires":[["eb9bacfc.3ef68"]]},{"id":"dcaf487.c8372b8","type":"file in","z":"d480ffdb.73b02","name":"","filename":"/home/pi//node/nrlive/.data/.config.json","format":"utf8","chunk":false,"sendError":false,"x":450,"y":300,"wires":[["84bd77cf.619268"]]},{"id":"84bd77cf.619268","type":"json","z":"d480ffdb.73b02","name":"","pretty":false,"x":670,"y":300,"wires":[["e1bdf411.316238","388ada2d.cb9c86","7c2f2610.dfcd68","5b712eaa.8e40b"]]},{"id":"439fdaa4.654984","type":"inject","z":"d480ffdb.73b02","name":"","repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":220,"y":300,"wires":[["dcaf487.c8372b8","31f77ef7.e173b2"]]},{"id":"31f77ef7.e173b2","type":"file in","z":"d480ffdb.73b02","name":"","filename":"C:\\src\\nr\\data\\.config.json","format":"utf8","chunk":false,"sendError":false,"x":390,"y":360,"wires":[["84bd77cf.619268"]]},{"id":"efe5de05.fc906","type":"comment","z":"d480ffdb.73b02","name":"Which nodes installed & what module provides each node?","info":"","x":370,"y":260,"wires":[]},{"id":"a1ffbab3.31f078","type":"debug","z":"d480ffdb.73b02","name":"","active":true,"console":"false","complete":"false","x":1030,"y":340,"wires":[]},{"id":"eb9bacfc.3ef68","type":"debug","z":"d480ffdb.73b02","name":"","active":true,"console":"false","complete":"false","x":1030,"y":380,"wires":[]}]

Note that the file name is actually missing 2 characters, it should be C:\src\nr\data\.config.json

The problem also happens if I add a new node with the same file name.

It doesn't happen if I use forward slashes instead of back-slashes.

Quick one: Should the current tab be highlighted in the info sidebar if I have a node selected?

If no nodes are selected, it is highlighted but if I click on a node, it isn't highlighted, I have to expand the tab entry and scroll to the highlighted entry.

there is now a feature that allows you to have linebreaks within the node label. Your \n then gets interpreted as a new line. Not sure how to fix that :slight_smile:

1 Like

:rofl: Good spot. Unexpected consequences indeed! Of course, I was one of those asking for that feature so it serves me right.

Sorry Nick, another edge-case to deal with.

Just to add that using double back-slashes does work as expected and shows the correct name in the editor (e.g. without the double slashes).

Possibly just the help info needs updating. Currently it says:

On Windows, path separators may need to be escaped, for example: \\Users\\myUser .

Perhaps it needs to say:

On Windows, path separators must be escaped, for example: C:\\Users\\myUser .

Note that I've included the drive letter at the start because the current example could be mistaken for a network shared drive URI.

2 Likes

Yes as you point out it's a side affect of allowing \n in names - but certainly for fields like that in the file nodes where we pick up the filename if no other name is specified it would make sense if we escaped it first so it displayed correctly.... of course if you do then type \n into the actual name field it would still "break".

Do shout if you spot other nodes that pick up file names rather too easiliy...

1 Like

I remember specifically asking the pr that added support for \n to handle paths as you'd expect without having to escape. I wonder why that hasnt worked here.

hmm yes back in https://github.com/node-red/node-red/pull/2242 - but not sure what was implemented to prevent it. Though this is the file node(s) - so more likely to come across it I grant you. Though I must admit I thought c:\newfile.txt would not work as a file name anyway as you have to \\ escape it in order to work - in which case we would then display c:\\newfile.txt as c:\newfile.txt.

On balance I think it would be safer to use "\n " as the newline delimiter when displaying node labels - we already trim whitespace after \n anyway.

1 Like

so line 2230 in view.js... are you in there anyway for other things ?

I don't know... I'm having my dinner. Maybe move this to slack?

@cymplecy what glitches are you seeing with groups? The only thing I've seen you mention is the label not disappearing when you clear it (which is already fixed btw)

I'm not having a direct problem with groups - I love them :slight_smile:

But I'm wondering if my other glitches are related to using them a lot e.g side effect as no-one else is reporting the glitches I'm having

I've just set up an @TotallyInformation alternate install using the beta so I can test outside of my main install

maybe obsolete now, since as far as I understand you are now targeting a general solution, but the exec node seems to be another candidate.
Not using windows myself, but would something like .\n argument also call a script with name n and argument argument under windows?

I believe we are specifically talking about how the node label can now contain newlines (which is a new feature in 1.1.0), rather than any one specific nodes handling of \n which isn't specific to the beta and should be discussed separately.

@cymplecy so as far as I know, everything you've reported regarding groups is fixed. I haven't looked at the link node item you mentioned yet, but it's on my list to look at.

yes, I understand that. I just wanted to point out that the solution with the additional whitespace \nWHITESPACE might also have an edge case in the exec node, if somebody uses \n bla (if that is even possible).
I can also see people using an exec node with something like ./script -m "I am a message \n but please don't do a linebreak"
Or I misunderstood your proposal here:

I am not talking about how a node interprets \n. I am talking about how the editor decides to split a node's label into multiple lines.

?? So do I?

exec

has the command ./script -m "I am a message \n but I don't want the label to linebreak"

You don't currently have to \\ things but \\ does work. I think what is happening is that the filename is being passed straight to the label but it should in fact be escaped to avoid the linebreak issue. Problem is that there are lots of exceptions. Though I think you may be handling most of them already - just the \n issue. Needs something like: replace \n with \\n but only if not already preceded by the extra \?

There will always be edge cases. We can't cater for them all, and we don't make special cases for specific nodes.

A user will still be able to set the name of the node to set the label to whatever they want... escaping any \n if they want.

Actually, personally I wouldn't care if the label showed a \n rather than linebreak there. It is a fairly exceptional case & if you really wanted the linebreak to appear you could simply copy the command to the name. But the filename issue is more serious because it looses some information along the way which is confusing. Seeing a \n in a command where you typed it into the command anyway is not confusing, just makes the node display rather long until you fix it by putting something into the name field.