# Function editor highlights text arbitrarily?

**URL:** <https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571>\
**Category:** General\
**Created:** [15 February 2024 16:45 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571 "2024-02-15T16:45:10Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 February 2024 19:21 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/21 "2024-02-15T19:21:54Z")

</div>

> [@Rgrove](#):
>
> Yeah, I'm going to do that, just need to dig through what that means, first.

You go back to ace and lose a lot of functionality including the ability to use most ES6 features (it doesn't understand them)

> [@Rgrove](#):
>
> but it's wholly dependent on the editor behaving like a standard text editor

Sorry, but I dont get your point. As far as i can see, it functions like pretty much any multi document editor. In your video, there is highlighted text and the cursor is blinking, and you proceeded to type. It is literally doing what you ask of it.

Here is a demonstration comparing Node-REDs editor to another MDI application - I see no differences (windows 11)

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/ebe1d29c562e8aa6da5ef41d9b48a177419b1196.jpeg "Monaco in Node-RED") ](https://www.youtube.com/watch?v=nF0ewV6wXnA)
  

If it is simply a case of the highlight not being clear, chose from one of the many included ones

For example, this is the ACE theme in monaco:  
 ![chrome_qUQTviSDps](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/1/c12d8cb83429a099700a6b2acbd7db05da378cc6.gif)

And here is a thread that shows you how to change the theme: [How to use themes with Monaco editor](https://discourse.nodered.org/t/how-to-use-themes-with-monaco-editor/48310)

Essetially set `codeEditor` -\> `options` -\> `theme` to `"ace"` or `"github-dark"` or any one of [59 options](https://github.com/node-red/node-red/tree/dev/packages/node_modules/%40node-red/editor-client/src/vendor/monaco/dist/theme) other themes included

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 February 2024 20:10 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/22 "2024-02-15T20:10:27Z")

</div>

FWIW I have had exactly the same problem with Monaco, it makes it very easy to accidentally delete code. I'd assumed I was accidentally getting fingers too close to the touchpad.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [15 February 2024 20:18 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/23 "2024-02-15T20:18:43Z")

</div>

Having seen similar things not related to node red. Replaced the wireless mouse. Who can tell...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 February 2024 20:31 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/24 "2024-02-15T20:31:09Z")

</div>

What version of nodejs are you using? Use `node -v` to find out.

---

<div class="post-metadata">

**Author:** ![Rgrove](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rgrove](https://discourse.nodered.org/u/Rgrove)\
**Post date:** [15 February 2024 20:40 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/25 "2024-02-15T20:40:42Z")

</div>

> [@Steve-Mcl](#):
>
> You go back to ace and lose a lot of functionality including the ability to use most ES6 features (it doesn't understand them)

Then I probably don't want to do that, and am back to the asking how to disable automatic highlighting.

> [@"Steve-Mcl](#):
>
> Sorry, but I dont get your point. As far as i can see, it functions like pretty much any multi document editor. In your video, there is highlighted text and the cursor is blinking, and you proceeded to type. It is literally doing what you ask of it.

What is not apparent in the video is that I don't hold down shift or drag the mouse. I just click, exit the editor, re-open the editor, click somewhere else, and everything in between the forgotten and irrelevant former click is suddenly highlighted.

So it's not doing what I asked. I asked it to put the cursor somewhere and instead from my perspective, it arbitrarily highlighted a bunch of text. I click and start typing because for 30 years, I've clicked in a document whitespace and started typing on faith that where I clicked is the sole place my cursor goes. If I asked it to highlight something, I'd click, hold down shift, then click somewhere else.

So to re-open a function text to edit, I essentially have to perform extra steps of clicking a couple times to get my cursor to a non-highlighted position.  
I can do that, but I have to retrain myself to remember there's a new way to function in this editor, and if I can turn that off instead of retraining myself, I'd rather turn it off.

---

<div class="post-metadata">

**Author:** ![Rgrove](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rgrove](https://discourse.nodered.org/u/Rgrove)\
**Post date:** [15 February 2024 20:43 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/26 "2024-02-15T20:43:27Z")

</div>

I'll look when I get home, had to go to work...

---

<div class="post-metadata">

**Author:** ![Rgrove](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rgrove](https://discourse.nodered.org/u/Rgrove)\
**Post date:** [15 February 2024 20:46 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/27 "2024-02-15T20:46:05Z")

</div>

That was my initial thought...the mouse is in a shop and I figured it was being a turd.  
But then it was Valentines day and I figured I couldn't hide in the shop, so I grabbed a laptop and sat on the couch with my wife... 😄 But it showed the same behavior on the laptop. Not connecting it, I did a full reboot on the laptop, with no change. Grabbed my work laptop and tried that, same thing.

---

<div class="post-metadata">

**Author:** ![Rgrove](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rgrove](https://discourse.nodered.org/u/Rgrove)\
**Post date:** [15 February 2024 20:47 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/28 "2024-02-15T20:47:53Z")

</div>

Did you solve it, or just deal with it?

I can deal with it if I have to, just am sure my pea brain will forget this in the 3 months between home system NR changes, and I'll stupidly lose content again before remembering it.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 February 2024 20:53 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/29 "2024-02-15T20:53:54Z")

</div>

This is not something that most of us see, so something odd is going on in both your system and @jbudd's

@jbudd, what version of node red and nodejs are you using?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [15 February 2024 20:59 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/30 "2024-02-15T20:59:11Z")

</div>

@Rgrove Nope, I have not fixed it.

@Colin Probably various versions on different devices but an example Node-red 3.1.5, node.js 18.19.1.

I can't pin down the circumstances when the editor misbehaves, just have to remember to check before typing.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 February 2024 21:01 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/31 "2024-02-15T21:01:07Z")

</div>

> [@jbudd](#):
>
> I can't pin down the circumstances when the editor misbehaves,

It seems that for @Rgrove every time he opens the function editor and then clicks in the code the text between the initial cursor position and where he clicks is selected and highlighted.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 February 2024 21:07 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/32 "2024-02-15T21:07:10Z")

</div>

@Rgrove ok, with your follow up messages and Colin's clear explanation I now understand. However I don't personally see this on win11 + chrome latest.

If you are willing to raise an issue I'll look into it.

---

<div class="post-metadata">

**Author:** ![Rgrove](https://avatars.discourse-cdn.com/v4/letter/r/5f8ce5/32.png) [@Rgrove](https://discourse.nodered.org/u/Rgrove)\
**Post date:** [15 February 2024 21:48 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/33 "2024-02-15T21:48:07Z")

</div>

It seems apparent now that this is a malfunction or unintended consequence of some other feature. I was baffled that anyone would want this behavior, but it doesn't seem that anyone actually does, and I probably explained it inadequately.

I'll try to get version numbers tonight when I get home.

Thanks all.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [15 February 2024 21:59 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/34 "2024-02-15T21:59:03Z")

</div>

> [@Steve-Mcl](#):
>
> What I don't understand is how you are ~~deleting~~ losing text?

They are losing text because of muscle memory - typing before the brain can react to things not being what is expected.

The unexpected is that the node is pre-selecting text when it shouldn't.

> [@Steve-Mcl](#):
>
> @Rgrove ok, with your follow up messages and Colin's clear explanation I now understand. However I don't personally see this on win11 + chrome latest.

I seem to vaguely remember we had a similar issue previously? Not quite the same though I don't think.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 February 2024 22:14 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/35 "2024-02-15T22:14:49Z")

</div>

> [@TotallyInformation](#):
>
> They are losing text because of muscle memory - typing before the brain can react to things not being what is expected

No, I don't think so now. it seems, from Colin's clear explanation when the op clicks in the code editor it is as if a new selection from the current cursor to the click point is made. As if the shift key is stuck down.

If you watch my video you will see (on my machine) it works totally "as expected".

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 February 2024 15:50 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/36 "2024-02-16T15:50:40Z")

</div>

> [@TotallyInformation](#):
>
> I seem to vaguely remember we had a similar issue previously?

I thought so to, but I can't find it.

---

<div class="post-metadata">

**Author:** ![samos](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samos](https://discourse.nodered.org/u/samos)\
**Post date:** [18 February 2024 06:15 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/37 "2024-02-18T06:15:40Z")

</div>

Hi All thought I'd jump in here to support Rgrove's situation. I get this too, and it started happening from approx 3.x For what it's worth, I run latest MacOS and Safari when editing code that's served on an RPI on the local LAN. However, I also see this when running the browser (usually Firefox ESR) natively on the RPi itself browsing to its localhost:1880 admin. For what it's worth, it behaves/_appears_ like the restoration of the cursor in-position in the function node's code has 'shift' pressed when the code opens, so that when you click the mouse into the code position, it therefore 'selects' from the last position...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2024 09:41 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/38 "2024-02-18T09:41:22Z")

</div>

> [@samos](#):
>
> it behaves/_appears_ like the restoration of the cursor in-position in the function node's code has 'shift' pressed when the code opens

On opening the function and moving the mouse about do you see text highlighting following the mouse as you move it?

---

<div class="post-metadata">

**Author:** ![samos](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samos](https://discourse.nodered.org/u/samos)\
**Post date:** [18 February 2024 10:58 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/39 "2024-02-18T10:58:08Z")

</div>

Hi Colin, no, not for me.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 February 2024 15:44 UTC](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571/40 "2024-02-18T15:44:58Z")

</div>

If you hold down and drag the mouse does it show an extending selection?

[Previous page](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571.md?page=1)

[Next page](https://discourse.nodered.org/t/function-editor-highlights-text-arbitrarily/85571.md?page=3)
