openhab-webui icon indicating copy to clipboard operation
openhab-webui copied to clipboard

Feature Request: Add Search and Replace Functionality to the Main UI Rule/Script Editor

Open BrettLHolmes opened this issue 6 months ago • 5 comments
trafficstars

The problem

It would be extremely helpful to have search and replace functionality in the Main UI’s rule and script editor. Currently, when working on larger DSL rules or UI-based scripts, making repetitive changes or locating specific variables or expressions requires manual scrolling and editing, which is time-consuming and error-prone.-

Requested Features: • Basic search (Ctrl+F) within the editor window. • Replace or replace-all functionality to make bulk edits quickly. • Optional: Regex support or case sensitivity toggle.

Use Case: Editing rules with repeated variable names, adjusting multiple states or command strings, or refactoring large blocks of code becomes significantly easier and faster with search/replace tools.

Your suggestion

Since the Main UI already uses CodeMirror, and CodeMirror includes official support for search and replace via its search and dialog addons, one possible enhancement path would be to enable these existing features in the current editor setup.

Your environment

openHAB 4.3.5 openhabian on Raspberry Pi 5 8Gb Ram


Additional information

BrettLHolmes avatar May 04 '25 07:05 BrettLHolmes

Basic search (Ctrl+F) within the editor window.

This already exists, but it's provided by the browser.

The rest would be nice additions.

rkoshak avatar May 05 '25 16:05 rkoshak

Based on @rkoshak 's response, can we update the description?

BrettLHolmes

stefan-hoehn avatar May 09 '25 18:05 stefan-hoehn

I don't know that the description is necessarily wrong here though. The browser provides find, but not replace. To get find and replace, that means transferring the find functionality from the browser to CodeMirror (or how ever that works).

My comment was just to point out that the whole "manual scrolling" part of the scenario outlined above isn't necessary now. Not to invalidate the whole issue.

rkoshak avatar May 09 '25 19:05 rkoshak

Based on @rkoshak 's response, can we update the description?

BrettLHolmes

Hi @stefan-hoen while i understand Rich’s comment is it fair to say that OH does not provide that search function. Which was the request.

Additionally if you try to use the browser based search it will highlight all items including items not in the editor (search for a number less than the number of lines in your widget, also if you do a paste [cmd-V on mac] all of the search is immediately de activated and you have to start the search again and so even the search does not work very well because it lacks any context

BrettLHolmes avatar May 12 '25 21:05 BrettLHolmes

Example: https://codemirror.net/5/demo/search.html

If someone wants to implement it.. feel free to jump in. Otherwise, I can give it a go when I have some time.

jimtng avatar Jun 26 '25 12:06 jimtng