RESOLVED DUPLICATE of bug 161159 153726
Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on save
https://bugs.webkit.org/show_bug.cgi?id=153726
Summary Web Inspector: CodeMirror converts tabs to 4 spaces, messes up indentation on...
Nikita Vasilyev
Reported 2016-01-30 22:26:05 PST
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.
Attachments
[Animated GIF] Bug (280.40 KB, image/gif)
2016-01-30 22:26 PST, Nikita Vasilyev
no flags
Radar WebKit Bug Importer
Comment 1 2016-01-30 22:26:18 PST
Nikita Vasilyev
Comment 2 2016-08-23 16:17:56 PDT
This should have tests, I don't see any in LayoutTests/inspector/css.
Devin Rousso
Comment 3 2016-08-24 19:00:45 PDT
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.
Nikita Vasilyev
Comment 4 2016-08-24 22:44:18 PDT
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 ***
Note You need to log in before you can comment on or make changes to this bug.