<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:dcrousso+webkit@gmail.com" title="Devin Rousso <dcrousso+webkit@gmail.com>"> <span class="fn">Devin Rousso</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on save"
href="https://bugs.webkit.org/show_bug.cgi?id=153726">bug 153726</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>dcrousso+webkit@gmail.com
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on save"
href="https://bugs.webkit.org/show_bug.cgi?id=153726#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on save"
href="https://bugs.webkit.org/show_bug.cgi?id=153726">bug 153726</a>
from <span class="vcard"><a class="email" href="mailto:dcrousso+webkit@gmail.com" title="Devin Rousso <dcrousso+webkit@gmail.com>"> <span class="fn">Devin Rousso</span></a>
</span></b>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>