Web Inspector: CSS autofill suggests properties instead of values when values are...
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / CodeMirrorFormatters.js
index 3d99cb64f2cbc7847210693f60f366b05960d6dc..840c0b3ee90bd1a694860938b2372412d3d7c355 100644 (file)
@@ -337,7 +337,7 @@ CodeMirror.extendMode("css", {
             if (content === ";")
                 return 1;
             if (content === ",") { // "a,b,c,...,z{}" rule list at top level or in @media top level and only if the line length will be large.
-                if ((!state.stack.length || state.stack.lastValue === "@media{") && state._cssPrettyPrint.lineLength > 60) {
+                if ((!state.stack || !state.stack.length || state.stack.lastValue === "@media{") && state._cssPrettyPrint.lineLength > 60) {
                     state._cssPrettyPrint.lineLength = 0;
                     return 1;
                 }
@@ -395,7 +395,7 @@ CodeMirror.extendMode("css", {
         // In order insert newlines in selector lists we need keep track of the length of the current line.
         // This isn't exact line length, only the builder knows that, but it is good enough to get an idea.
         // If we are at a top level, keep track of the current line length, otherwise we reset to 0.
-        if (!state.stack.length || state.stack.lastValue === "@media{")
+        if (!state.stack || !state.stack.length || state.stack.lastValue === "@media{")
             state._cssPrettyPrint.lineLength += content.length;
         else
             state._cssPrettyPrint.lineLength = 0;