Файли
openidea/src/platform/editorSettings.test.ts
T
astesiaтаkirito1105 607812d8fa feat(editor): make the code insight file size limit configurable (#7461)
Settings › Editor gains a code insight file size limit (default 5 MiB). Files above it open without syntax analysis and language servers, with a banner saying why.

The size decision is fixed for each open document so syntax and LSP registration agree across reloads, the hard editing limit and undo snapshot budget stay independent, and read-only files above the limit get the right banner.

Co-authored-by: kirito1105 <[email protected]>
2026-12-02 20:07:47 +08:00

49 рядки
2.2 KiB
TypeScript

import { expect, it } from "vitest";
import { EDITOR_EXTRA_DEFAULTS, validateEditorExtras } from "./editorSettings";
it("reads whole-number code insight limits from 1 to 50 MiB and defaults to 5", () => {
expect(validateEditorExtras(undefined).maxCodeInsightFileSizeMb).toBe(5);
for (const value of [1, 10, 50]) {
expect(validateEditorExtras({ maxCodeInsightFileSizeMb: value }).maxCodeInsightFileSizeMb).toBe(value);
}
for (const value of [0, 51, 3.5, "10"]) {
expect(validateEditorExtras({ maxCodeInsightFileSizeMb: value }).maxCodeInsightFileSizeMb).toBe(5);
}
});
it("has no encoding mappings unless the settings name some", () => {
expect(EDITOR_EXTRA_DEFAULTS.encodings.mappings).toEqual({});
expect(validateEditorExtras(undefined).encodings.mappings).toEqual({});
expect(validateEditorExtras({ encodings: { mappings: "gbk" } }).encodings.mappings).toEqual({});
});
it("keeps the encoding mappings that name a label", () => {
const raw = {
encodings: { project: "gbk", mappings: { "src/main/java": "iso-8859-15", "src/A.java": 5, lib: null } },
};
const { encodings } = validateEditorExtras(raw);
expect(encodings.mappings).toEqual({ "src/main/java": "iso-8859-15" });
expect(encodings.project).toBe("gbk");
});
it("defaults to whole-line copy, copied-line selection, and paste above", () => {
expect(validateEditorExtras(undefined).smartKeys).toMatchObject({
copyLineWhenNoSelection: true,
selectCopiedLine: true,
linePasteMode: "above",
});
});
it("validates every line clipboard option", () => {
expect(
validateEditorExtras({
smartKeys: { copyLineWhenNoSelection: false, selectCopiedLine: false, linePasteMode: "trim" },
}).smartKeys,
).toMatchObject({ copyLineWhenNoSelection: false, selectCopiedLine: false, linePasteMode: "trim" });
expect(validateEditorExtras({ smartKeys: { linePasteMode: "caret" } }).smartKeys.linePasteMode).toBe("caret");
expect(validateEditorExtras({ smartKeys: { linePasteMode: "sideways" } }).smartKeys.linePasteMode).toBe("above");
expect(
validateEditorExtras({ smartKeys: { copyLineWhenNoSelection: "no", selectCopiedLine: 0 } }).smartKeys,
).toMatchObject({ copyLineWhenNoSelection: true, selectCopiedLine: true });
});