Function editor highlights text arbitrarily?

I recently upgraded my home NR, and am now finding when I open a function node to edit, as soon as I click the code/text I want to change, it highlights a whole block between where I'd last left the cursor and just clicked on this edit session. Happening on both a desktop with a mouse and a laptop with a touchpad.

This wiped out a bunch of arbitrary lines I'd been tweaking, so it's very frustrating.

Is there a new setting I'm missing?

edit: just identified that it remembers where I left the cursor at last edit, and on next edit, highlights everything from the last cursor position to wherever I click now.

Don't worry about it is just highlighting the text block, it has not selected it, it is a feature of the Monaco editor. Node-red has changed to Monaco fro ace.

Should not of wiped any lines can you share an image?

You can always press ctrl z to go back.

If it's inadvertantly making me erase work, I should probably worry about it.

It wipes because I get a concept in my head, click where I want to edit it, and start typing, then hit save, deploy, and get an error. Or, I close it and see the red triangle, etc.And on a laptop LCD, the contrast is apparently not strong enough to always see that it highlighted something.
Yes, I get that I'm responsible for my work, but this is like the crappy upgrades forced down by every other tech conglomerate, where they change something randomly and it screws up all your muscle-memory work habits.

Normal behavior in text editors is to highlight when you click and hold or click and hold a key combo. This is a bizarre deviation from "normal" expectations.

Again it should not delete the highlighted text.
Again can you share an image , so we can see the issue, as there may be some conflict etc.

You can revert back to ace if you want there is a setting in the settings.js file.

I don't know how helpful the image is, but here it is. I clicked the bottom cursor position, closed the editor window, moved the node around the flow, re-opened the editor, clicked the top cursor position, and everything you see was highlighted.


If I'd left the editor by changing one of these entrees, then returned to change a different entry, it's entirely possible to wipe out a section of conditional statements and not even notice if I was focused on other coding work.

Are you saying when you type in the highlighted section the whole section is over written?

That's correct, which is the standard behavior of a text editor. Highlight, type, and the typing replaced the highlighting.

A feature request was fulfilled quite some time ago, to enable remembering users selection and scroll position so they don't have to hunt for where they were up to over and over.

This should be per node (i.e. function 1 remembers it's scroll and highlight different to where you left scroll and highlight in function 2)

What I don't understand is how you are deleting losing text?

Typically you move your cursor before typing? Or at least look at where it is blinking before typing.

This is similar to switching tabs in an mdi application - they are maintained. I'd be super unhappy if the cursor kept losing selection and positioning and scrolling to the top.

No, I have to highlight the section blue to overwrite.

Steve is replying to this topic he added the Monaco editor, wait a second.

Are you on windows and have you selected the insert key by any chance?

Here's a quick video. I have to assume you're not understanding or I'm not describing the issue well when you say it shouldn't clear the text.

I'm on windows, but no insert key. This is happening on varying different PC's.

It appears my next rabbit hole is how to ditch the monaco editor. Thanks.

I can see the utility on very long code sections, but even then (I have some huge functions in an experimental system), why does it highligjht as if I'd held down shift? I'd expect the editor to behave like an editor, without a custom nuance.

If it's a feature, can it be disabled?
Going by E1cid's comments, I'm going to look for how to change Monaco. THe whole concept of an editor within the editor is new to me, so it's a task for another day.

I think this was reported by someone else a little time ago. Are you using the latest version of node red, 3.1.5?


I just updated it recently, though.
Any idea if this behavior is different in the current version?
I've had updates kill mission-critical systems in my career, so I don't update unless it's to solve a specific problem.

Now it's really my own fault...literally talking about it, and I just opened a function, clicked an empty space, then hit ctrl-v to paste in code from another node (consolidating multiple functions), and wiped out the existing code because my fingers moved faster than my eyes seeing it highlighted.
Hit cancel, started over and did it right, so nothing lost. Still annoying to remember different text editing behaviors when I'm working on several things at once (working my day job right now also, so typing emails and editing spreadsheets).

`You hit cancel after you add the comment, that will revert back to before you added the comment, you have to hit done to save. Or am I still missing the issue?
Ĩ see the issue now watched a few times, this is not happening for me, I have to press and drag or use shift, it then highlights blue, only then does it over write. If grey it just inserts when cursor is.

You don't have to hit cancel you can press ctrl z to undo.

Yes. I hit cancel for the sake of the video.

Here are the steps that lead to data loss in the video:

  • open editor
  • change some text
  • hit done and move to next task
  • bugs appear to be worked out, time to comment, so return to the function node editor
  • click in whitespace
  • start typing, see noise (error flags), realize I forgot the backslashes, so add them, then continue commenting
  • hit done, now having replaced my working code with a comment.

Yeah, I acknowledge that it's a very dumb-mistake scenario, but it's wholly dependent on the editor behaving like a standard text editor. I also realized after this post, that I'm conditioned to ignore text highlighting because some text seems to be arbitrarily highlighted. I just opened the editor to change a test variable, and saw the line highlighted, typed the new variable value, and the higlighting didn't change. Like different colored line or something.

As mentioned before you can revert to Ace in the settings.js, if you want the old behaviour.

Yeah, I'm going to do that, just need to dig through what that means, first.

I don't mean to be whiny, just getting more frustrated as I explore it.