<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:dcrousso+webkit&#64;gmail.com" title="Devin Rousso &lt;dcrousso+webkit&#64;gmail.com&gt;"> <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>
               &nbsp;
           </td>
           <td>dcrousso+webkit&#64;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&#64;gmail.com" title="Devin Rousso &lt;dcrousso+webkit&#64;gmail.com&gt;"> <span class="fn">Devin Rousso</span></a>
</span></b>
        <pre>I tried messing around with changing the default keymap of &quot;Enter&quot; to be something like:

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

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 &quot;hacky&quot; 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(&quot;indentWithTabs&quot;, tabs &amp;&amp; tabs.length &gt;= 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>