Bug 503455 - Kate command line: regex not working
Summary: Kate command line: regex not working
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: kwrite (other bugs)
Version First Reported In: 25.04.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-04-28 01:43 UTC by vassari
Modified: 2025-06-01 10:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vassari 2025-04-28 01:43:30 UTC
SUMMARY

Since a few months ago, when I press F7 to open the command line in Kate and try to use a regular expression like:

%s/foo/bar/
it shows the error: Command "%s/foo/bar/" failed.

If I type:

s/foo/bar/

it works—but only on the line where the cursor is.

Does anyone know what's going on?

I'm using Arch Linux. I also installed the Flatpak version of Kate (following the link from the official website), and the same behavior happens there.

Regards.

STEPS TO REPRODUCE
1.  Open Kate. 
2. Write some lines of text.
3. Press F7 to open the command line. 
4. Type %s /foo/bar (or %s/foo/bar/)

OBSERVED RESULT
I get:
Command "%s /foo/bar/" failed.


EXPECTED RESULT

It should replace foo for bar in all the lines.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma:  Arch Linux
KDE Plasma Version:  6.3.4
KDE Frameworks Version: 6.13.0 
Qt Version: 6.9.0

ADDITIONAL INFORMATION
Comment 1 Christoph Cullmann 2025-04-29 15:40:58 UTC
CommandRangeExpressionParser::parseRangeExpression seems to not properly parse that, it doesn't enter the

 if (match.hasMatch() && match.capturedLength(0) > 0) {
        commandTmp.remove(m_cmdRangeRegex);

code path at all.
Comment 2 vassari 2025-05-15 09:55:55 UTC
(In reply to Christoph Cullmann from comment #1)
> CommandRangeExpressionParser::parseRangeExpression seems to not properly
> parse that, it doesn't enter the
> 
>  if (match.hasMatch() && match.capturedLength(0) > 0) {
>         commandTmp.remove(m_cmdRangeRegex);
> 
> code path at all.

Hi,

so, is something gonna happend with this?

Any idea?

Regards.
Comment 3 Christoph Cullmann 2025-05-31 14:31:16 UTC
(In reply to vassari from comment #2)
> (In reply to Christoph Cullmann from comment #1)
> > CommandRangeExpressionParser::parseRangeExpression seems to not properly
> > parse that, it doesn't enter the
> > 
> >  if (match.hasMatch() && match.capturedLength(0) > 0) {
> >         commandTmp.remove(m_cmdRangeRegex);
> > 
> > code path at all.
> 
> Hi,
> 
> so, is something gonna happend with this?
> 
> Any idea?
> 
> Regards.

Beside tracing it down to that location, I had no time to fix that.
If somebody else has time to look at that in more detail, help is welcome.
Comment 4 Bug Janitor Service 2025-06-01 09:18:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/814
Comment 5 Waqar Ahmed 2025-06-01 10:31:11 UTC
Git commit 6b88616baf6b66c941d9f4ef84f6277da07519df by Waqar Ahmed.
Committed on 01/06/2025 at 09:42.
Pushed by cullmann into branch 'master'.

Fix m_marks not initialized

This got lost during refactorings years ago

The bigger problem here is that we have 2 copies of this class, one
in ViMode and this one. The ViMode one seems to be the maintained
variant so we should drop this class soon and use the same class
everywhere.

M  +22   -0    autotests/src/kateview_test.cpp
M  +1    -0    autotests/src/kateview_test.h
M  +1    -0    src/utils/katecommandrangeexpressionparser.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/6b88616baf6b66c941d9f4ef84f6277da07519df