This is 2.13 exercise in Erdmann and Wildon's book.
Define a center $$ Z(L) = \{ z\in L |\ [z,x]=0\ \forall \ x\in L \} $$
If $I$ is ideal of $L$ then let $$ B = C_L(I) = \{ z\in L|\ [z,x]=0\ \forall x\in I \} $$ (It is called by centralizer of $I$. So $B$ is ideal of $L$)
Consider the following conditions
(1) $Z(I)=0$
(2) If $D$ is a derivation on $I$ then $D = {\rm ad}_x$ for some $x\in I$
Then $$ L= I \oplus B$$
I have no skill or experience in Lie algebra. Thank you.
By the definition of $B$, we have $[I,B]=0$.
If $x\in I\cap B$, then $x\in Z(I)=0$, so $I\cap B=0$.
For any $x\in L$, we can restrict $\mathrm{ad}_{x}$ on $I$. By (2), there exists $x_I\in I$ s.t. $\mathrm{ad}_{x}\big|_{I}=ad_{x_{I}}$. It's obivious that $x-x_{I}\in B$ since$$\mathrm{ad}_{x}\big|_{I}(y)=ad_{x_{I}}(y)\iff[x-x_I,y]=0$$for every $y\in I$.
To sum up, we get $L=I\oplus B$.