Skip to content

Always display newlines in find-and-replace result when contained #175

@WebCoder49

Description

@WebCoder49

Should be quick to fix.

Steps to reproduce:

  • Use this code:
<!DOCTYPE html>
<html>
    <body>
        <!--Prism+code-input-->
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-core.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/plugins/autoloader/prism-autoloader.min.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css"></link>
        <script src="https://cdn.jsdelivr.net/gh/WebCoder49/[email protected]/code-input.min.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/[email protected]/code-input.min.css">

        <!--Import-->
        <script src="https://cdn.jsdelivr.net/gh/WebCoder49/[email protected]/plugins/find-and-replace.min.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/[email protected]/plugins/find-and-replace.min.css"/>

        <script>
            let findAndReplacePlugin = new codeInput.plugins.FindAndReplace(
                true, // Should Ctrl+F be overriden for find-and-replace find functionality? Either way, you can also trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, false)`.
                true, // Should Ctrl+H be overriden for find-and-replace replace functionality? Either way, you can also trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, true)`.
            );
            // Programatically opening the dialogs, to integrate with your user interface
            function find() {
                findAndReplacePlugin.showPrompt(document.querySelector("code-input"), false);
            }
            function replace() {
                findAndReplacePlugin.showPrompt(document.querySelector("code-input"), true);
            }
            codeInput.registerTemplate("syntax-highlighted", codeInput.templates.prism(Prism, [
                // Pass at register
                findAndReplacePlugin
            ]));
        </script>
        <p>When focused in the editor: Try Ctrl+F, or click <button onclick="find();">this</button> to find. Try Ctrl+H, or click <button onclick="replace();">this</button> to replace.</p>
        <code-input language="markdown"># Hickory dickory dock
Hickory dickory dock.
The mouse ran up the clock.
The clock struck one,
The mouse ran down,
Hickory dickory dock.</code-input>
    </body>
</html>
  • Ctrl+F for .\n., turning regular expression mode on.

Observed result:

Screenshot: only first match shows the newline visually

Expected result:
newline indicator present on every line

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:existing-pluginA bug/feature for an existing plugin in the plugins folder of code-input.bugSomething isn't workingpriority:medium

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions