M2.2: PHP highlighting, syntax colour tokens and editor.reveal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f13a49064d
commit
6c75c08d70
25 changed files with 1044 additions and 33 deletions
|
|
@ -107,8 +107,8 @@ export const useEditorStore = defineStore("editor", () => {
|
|||
let timedStart = 0;
|
||||
/** Engine transport for syncs, replaceable in tests. */
|
||||
let transport: SyncTransport = engineTransport;
|
||||
/** Extensions of new editor states, replaceable in tests. */
|
||||
let extensions: () => Extension = editorExtensions;
|
||||
/** Extensions of a new editor state for a file path, replaceable in tests. */
|
||||
let extensions: (path: string) => Extension = editorExtensions;
|
||||
/** Counter of tab adoptions, so only the newest open activates its tab. */
|
||||
let openSequence = 0;
|
||||
/** Unsubscribe function of the event subscription. */
|
||||
|
|
@ -139,9 +139,9 @@ export const useEditorStore = defineStore("editor", () => {
|
|||
* Replaces the engine transport and editor extensions (tests).
|
||||
*
|
||||
* @param next - transport for new syncs.
|
||||
* @param nextExtensions - extensions for new editor states.
|
||||
* @param nextExtensions - extensions for new editor states, by file path.
|
||||
*/
|
||||
function configure(next: SyncTransport, nextExtensions?: () => Extension): void {
|
||||
function configure(next: SyncTransport, nextExtensions?: (path: string) => Extension): void {
|
||||
transport = next;
|
||||
if (nextExtensions) {
|
||||
extensions = nextExtensions;
|
||||
|
|
@ -160,7 +160,7 @@ export const useEditorStore = defineStore("editor", () => {
|
|||
const started = openStarted.get(info.path);
|
||||
syncs.set(
|
||||
info.id,
|
||||
new BufferSync(info, extensions(), transport, (error) => {
|
||||
new BufferSync(info, extensions(info.path), transport, (error) => {
|
||||
const tab = tabOf(info.id);
|
||||
if (tab) {
|
||||
tab.notice = { kind: "error", message: error.message };
|
||||
|
|
@ -211,22 +211,25 @@ export const useEditorStore = defineStore("editor", () => {
|
|||
* Opens a file in a tab (or activates its tab).
|
||||
*
|
||||
* @param path - project-relative path.
|
||||
* @returns the buffer id of the tab, or null if the open failed
|
||||
* ({@link lastError} says why).
|
||||
*/
|
||||
async function openFile(path: string): Promise<void> {
|
||||
async function openFile(path: string): Promise<number | null> {
|
||||
openStarted.set(path, performance.now());
|
||||
const result = await run<unknown>(EDITOR_COMMANDS.open, { path });
|
||||
if (!result.ok) {
|
||||
openStarted.delete(path);
|
||||
lastError.value = result.error;
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (!isBufferInfo(result.value)) {
|
||||
lastError.value = { code: "ipc", message: t("common.error.unexpectedResult", { command: EDITOR_COMMANDS.open }) };
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
lastError.value = null;
|
||||
openSequence += 1;
|
||||
adopt(result.value);
|
||||
return result.value.id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue