# CodeEditorComponent lookAndFeelChanged caret handling

**URL:** <https://forum.juce.com/t/codeeditorcomponent-lookandfeelchanged-caret-handling/45777>\
**Category:** General JUCE discussion\
**Created:** [April 30, 2021, 3:17pm UTC](https://forum.juce.com/t/codeeditorcomponent-lookandfeelchanged-caret-handling/45777 "2021-04-30T15:17:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![graeme](https://avatars.discourse-cdn.com/v4/letter/g/50afbb/32.png) [@graeme](https://forum.juce.com/u/graeme)\
**Post date:** [April 30, 2021, 3:17pm UTC](https://forum.juce.com/t/codeeditorcomponent-lookandfeelchanged-caret-handling/45777/1 "2021-04-30T15:17:24Z")

</div>

Hi, I noticed a fix for the caret reset handling in commit bcb85bc752f6fce28c50abe22cfa5baf853eee74. Should it be checking the read only state before assuming addAndMakeVisible is correct action? And although unlikely to happen, should it not have some kind of handling for a badly behaving createCaretComponent impl returning null?

> <https://github.com/juce-framework/JUCE/commit/bcb85bc752f6fce28c50abe22cfa5baf853eee74>

```auto
void CodeEditorComponent::lookAndFeelChanged()
{
    caret.reset (getLookAndFeel().createCaretComponent (this));
    addAndMakeVisible (*caret);
}

```

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [April 30, 2021, 4:16pm UTC](https://forum.juce.com/t/codeeditorcomponent-lookandfeelchanged-caret-handling/45777/2 "2021-04-30T16:16:15Z")

</div>

Yep we’ll get that sorted out, thanks!
