From 150c9de6fb6d89cb165814715d5bd5b7d7ef25c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Mon, 13 Apr 2026 17:50:52 +0200 Subject: [PATCH] fix snippets --- client/components/codeEditor/codeEditor.jsx | 16 +++------------- client/homebrew/editor/editor.jsx | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/client/components/codeEditor/codeEditor.jsx b/client/components/codeEditor/codeEditor.jsx index 4fa19b382..b732bf9c8 100644 --- a/client/components/codeEditor/codeEditor.jsx +++ b/client/components/codeEditor/codeEditor.jsx @@ -355,21 +355,11 @@ const CodeEditor = forwardRef( injectText : (text)=>{ const view = viewRef.current; - const changes = view.state.selection.ranges.map((range)=>({ - from : range.from, - to : range.to, - insert : text - })); - const newRanges = view.state.selection.ranges.map((range)=>({ - anchor : range.from + text.length - })); - - view.dispatch({ - changes, - selection : { ranges: newRanges } - }); + view.dispatch( + view.state.replaceSelection(text) + ); view.focus(); }, getCursorPosition : ()=>viewRef.current.state.selection.main.head, diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index adabecc0b..b34bdd94a 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -150,7 +150,7 @@ const Editor = createReactClass({ }, handleInject : function(injectText){ - this.codeEditor.current?.injectText(injectText, false); + this.codeEditor.current?.injectText(injectText); }, handleViewChange : function(newView){