дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
Properties documents passed through charset decoding alone, leaving Unicode escapes in the shared document text. - Add a default-off "Transparent native-to-ascii conversion" setting under the properties encoding and a stable action. Changing it reloads clean properties buffers in place; dirty buffers keep their codec. - Decode eligible escapes and surrogate pairs when constructing documents, and save non-ASCII as uppercase escapes in pure ASCII. Backslash pairs, malformed escapes, unpaired surrogates and line terminator escapes stay literal, so an edit cannot split a property across lines. - Use the same codec for search, closed-file readers, Git diffs, staging and partial commits. Clean saves and undone edits preserve the original bytes. Fixes #519
33 рядки
1.1 KiB
TypeScript
33 рядки
1.1 KiB
TypeScript
import type { Action } from "@/platform/actions";
|
|
import { call, commands } from "@/platform/ipc";
|
|
import { loadSettings, useProject } from "@/platform/project";
|
|
import { stage, type Scope } from "./model/staging";
|
|
|
|
export const NATIVE_TO_ASCII_ACTION = "editor.encodings.toggleNativeToAscii";
|
|
const KEY = "editor.encodings.nativeToAscii";
|
|
|
|
export function nativeToAsciiAction(): Action {
|
|
return {
|
|
id: NATIVE_TO_ASCII_ACTION,
|
|
title: "Transparent native-to-ascii conversion",
|
|
category: "Editor",
|
|
keywords: ["properties", "encoding", "Unicode"],
|
|
run: async ({ arg }) => {
|
|
const staged = arg as { pageId?: string; scope?: Scope; value?: boolean } | undefined;
|
|
if (staged?.pageId && staged.scope && typeof staged.value === "boolean") {
|
|
stage(staged.pageId, staged.scope, KEY, staged.value);
|
|
return;
|
|
}
|
|
const { settings, project } = useProject.getState();
|
|
await call(
|
|
commands.settingsSet(
|
|
project ? "project" : "global",
|
|
KEY,
|
|
JSON.stringify(!settings?.editor?.encodings?.nativeToAscii),
|
|
),
|
|
);
|
|
await loadSettings();
|
|
},
|
|
};
|
|
}
|