MCPcopy Index your code
hub / github.com/prettydiff/prettydiff / destructfix

Function destructfix

beautify/script.ts:152–219  ·  view source on GitHub ↗
(listFix:boolean, override:boolean)

Source from the content-addressed store, hash-verified

150 }
151 },
152 destructfix = function beautify_script_level_destructFix(listFix:boolean, override:boolean):void {
153 // listfix - at the end of a list correct the containing list override - to
154 // break arrays with more than 4 items into a vertical list
155 let c:number = a - 1,
156 d:number = (listFix === true)
157 ? 0
158 : 1;
159 const ei:number[] = (extraindent[extraindent.length - 1] === undefined)
160 ? []
161 : extraindent[extraindent.length - 1],
162 arrayCheck:boolean = (
163 override === false && data.stack[a] === "array" && listFix === true && ctoke !== "["
164 );
165 if (destruct[destruct.length - 1] === false || (data.stack[a] === "array" && options.formatArray === "inline") || (data.stack[a] === "object" && options.format_object === "inline")) {
166 return;
167 }
168 destruct[destruct.length - 1] = false;
169 do {
170 if (data.types[c] === "end") {
171 d = d + 1;
172 } else if (data.types[c] === "start") {
173 d = d - 1;
174 }
175 if (data.stack[c] === "global") {
176 break;
177 }
178 if (d === 0) {
179 if (data.stack[a] === "class" || data.stack[a] === "map" || (arrayCheck === false && ((listFix === false && data.token[c] !== "(" && data.token[c] !== "x(") || (listFix === true && data.token[c] === ",")))) {
180 if (data.types[c + 1] === "template_start") {
181 if (data.lines[c] < 1) {
182 level[c] = -20;
183 } else {
184 level[c] = indent - 1;
185 }
186 } else if (ei.length > 0 && ei[ei.length - 1] > -1) {
187 level[c] = indent - 1;
188 } else {
189 level[c] = indent;
190 }
191 } else if (data.stack[a] === "array" && data.types[a] === "operator") {
192 if (data.token[c] === ",") {
193 level[c] = indent;
194 }
195 if (c === data.begin[a]) {
196 break;
197 }
198 }
199 if (listFix === false) {
200 break;
201 }
202 }
203 if (d < 0) {
204 if (data.types[c + 1] === "template_start") {
205 if (data.lines[c] < 1) {
206 level[c] = -20;
207 } else {
208 level[c] = indent - 1;
209 }

Callers 6

commentFunction · 0.85
endFunction · 0.85
markupFunction · 0.85
operatorFunction · 0.85
separatorFunction · 0.85
startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected