[Webkit-unassigned] [Bug 153726] Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on save

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 24 19:00:45 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=153726

Devin Rousso <dcrousso+webkit at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcrousso+webkit at gmail.com

--- Comment #3 from Devin Rousso <dcrousso+webkit at gmail.com> ---
I tried messing around with changing the default keymap of "Enter" to be something like:

"Enter": (codeMirror) => {
    let doc = codeMirror.getDoc();
    doc.replaceRange("\n", doc.getCursor());
    codeMirror.indentLine(doc.getCursor().line, "prev");
}

This will create the newline at the expected place, but it doesn't seem to want to indent it based on the previous line.  Another "hacky" option would be to toggle `indentWithTabs` based on the number of tab characters in the editor:

let tabs = codeMirror.getValue().match(/\n\t+/g);
codeMirror.setOption("indentWithTabs", tabs && tabs.length >= codeMirror.lineCount() / 2);

I think the first option is better, but it also isn't perfect as it bases the indentation solely on the previous line, meaning that if a single line uses tabs instead of spaces, all newlines off of that line will have tabs too.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160825/63767876/attachment.html>


More information about the webkit-unassigned mailing list