MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / buildFormattingOptions

Function buildFormattingOptions

src/cm/lsp/clientManager.ts:1249–1276  ·  view source on GitHub ↗
(
  view: EditorView,
  overrides: FormattingOptions = {},
)

Source from the content-addressed store, hash-verified

1247}
1248
1249function buildFormattingOptions(
1250 view: EditorView,
1251 overrides: FormattingOptions = {},
1252): FormattingOptions {
1253 const state = view?.state;
1254 if (!state) return { ...overrides };
1255
1256 const unitValue = state.facet(indentUnit);
1257 const unit =
1258 typeof unitValue === "string" && unitValue.length
1259 ? unitValue
1260 : String(unitValue ?? "\t");
1261 let tabSize = getIndentUnit(state);
1262 if (
1263 typeof tabSize !== "number" ||
1264 !Number.isFinite(tabSize) ||
1265 tabSize <= 0
1266 ) {
1267 tabSize = resolveIndentWidth(unit);
1268 }
1269 const insertSpaces = !unit.includes("\t");
1270
1271 return {
1272 tabSize,
1273 insertSpaces,
1274 ...overrides,
1275 };
1276}
1277
1278function resolveIndentWidth(unit: string): number {
1279 if (typeof unit !== "string" || !unit.length) return 4;

Callers 1

formatDocumentMethod · 0.85

Calls 2

StringInterface · 0.85
resolveIndentWidthFunction · 0.85

Tested by

no test coverage detected