Skip to content

mcedit search/replace in selection: s/^/foo/ unexpectedly replaces EOL of last line #4751

@GfEW

Description

@GfEW

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

GNU Midnight Commander 4.8.33-334-g9ec954aaf
Built with GLib 2.80.0 (using GLib 2.80.0)
Built with S-Lang 2.3.3 and terminfo database (using S-Lang 2.3.3)
With builtin editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With internationalization support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, shell
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64; uintmax_t: 64;

Operating system

Linux codespaces-08a020 6.8.0-1030-azure #35~22.04.1-Ubuntu SMP Mon May 26 18:08:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

Example text:

echo foo
echo "start selection at beginning of this line"
echo "extend selection moving strictly downwards (never left/right) across lines"
echo "this is the last line to be included in the selection"
echo "finish selection at beginning of this line"
echo bar

Search pattern:

^

Replacement pattern:

\t#

Options:

  • Pattern type: Regular expression
  • Case sensitive
  • Backwards
  • In selection
  • Whole words
  • All charsets

Expected behavior

Expected result:

echo foo
        # echo "start selection at beginning of this line"
        # echo "extend selection moving strictly downwards (never left/right) across lines"
        # echo "this is the last line to be included in the selection"
echo "finish selection at beginning of this line"
echo bar

I. e., all BOLs in the selected lines, and nothing else, should be replaced.

Actual behavior

Actual result:

echo foo
        # echo "start selection at beginning of this line"
        # echo "extend selection moving strictly downwards (never left/right) across lines"
        # echo "this is the last line to be included in the selection"   # 
echo "finish selection at beginning of this line"
echo bar

I. e., EOL in the last selected line is also replaced.

Additional context

This bug looks just as closely related to #4072 as #4743, #4744, #4745, but unlike the latter, it is still present.

Metadata

Metadata

Assignees

Labels

area: mceditmcedit, the built-in text editorprio: mediumHas the potential to affect progressstate: approvedIf not using PRs: associated branch has been approved

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions