Created attachment 270338 [details] [Animated GIF] Bug See the attached GIF. Steps: 1. Open http://nv.github.io/webkit-inspector-bugs/css-saving-indentation/ 2. Open style.css in Resources Expected: Tab characters that are used for indentation are preserved as tabs. Actual: Tab characters were replaced with four spaces. As a result of that, editing CSS messes up with indentation.
<rdar://problem/24428409>
This should have tests, I don't see any in LayoutTests/inspector/css.
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.
The actual problem here is: Web Inspector: Minification detection produces false positives for small resources https://bugs.webkit.org/show_bug.cgi?id=161159 In the animated GIF you can see that pretty printing is on, even though it shouldn't be enabled by default. When it's on, tabs are replaced by 4 spaces. When pretty printing is off, tab characters get preserved as expected. *** This bug has been marked as a duplicate of bug 161159 ***