Edit workspace files directly on web (#2270)

* feat(files): edit workspace files on web

Keep source buffers synchronized with host file changes and require an explicit overwrite or reload when revisions diverge.

* feat(panels): surface and protect modified tabs

Expose tooltip and modification state through the generic panel boundary so tabs can show stable metadata and guard every close route consistently.

* fix(tests): use portable fake timeout handle

* fix(files): harden editor conflict handling

Preserve modified panel state across tab eviction, use precise revisions for optimistic writes, coalesce concurrent file watchers, and localize the editor interface.

* fix(files): close editor concurrency gaps

Coalesce clean reloads, preserve subscriber identities and file permissions, suspend pending saves during close confirmation, and carry precise revisions through file reads.

* test(files): expect read revision metadata
This commit is contained in:
Mohamed Boudra
2026-07-21 04:41:19 +08:00
committed by GitHub
parent 9292f58896
commit 4bda2dfea9
69 changed files with 3678 additions and 241 deletions
+3 -45
View File
@@ -1,50 +1,8 @@
import { highlightTree, tagHighlighter, tags } from "@lezer/highlight";
import { highlightTree } from "@lezer/highlight";
import type { HighlightStyle, HighlightToken } from "./types.js";
import { getParserForFile } from "./parsers.js";
const highlighter = tagHighlighter([
{ tag: tags.keyword, class: "keyword" },
{ tag: tags.controlKeyword, class: "keyword" },
{ tag: tags.operatorKeyword, class: "keyword" },
{ tag: tags.definitionKeyword, class: "keyword" },
{ tag: tags.moduleKeyword, class: "keyword" },
{ tag: tags.comment, class: "comment" },
{ tag: tags.lineComment, class: "comment" },
{ tag: tags.blockComment, class: "comment" },
{ tag: tags.docComment, class: "comment" },
{ tag: tags.string, class: "string" },
{ tag: tags.special(tags.string), class: "string" },
{ tag: tags.number, class: "number" },
{ tag: tags.integer, class: "number" },
{ tag: tags.float, class: "number" },
{ tag: tags.bool, class: "literal" },
{ tag: tags.null, class: "literal" },
{ tag: tags.function(tags.variableName), class: "function" },
{ tag: tags.function(tags.propertyName), class: "function" },
{ tag: tags.definition(tags.variableName), class: "definition" },
{ tag: tags.definition(tags.propertyName), class: "definition" },
{ tag: tags.definition(tags.function(tags.variableName)), class: "definition" },
{ tag: tags.className, class: "class" },
{ tag: tags.definition(tags.className), class: "class" },
{ tag: tags.typeName, class: "type" },
{ tag: tags.tagName, class: "tag" },
{ tag: tags.attributeName, class: "attribute" },
{ tag: tags.attributeValue, class: "string" },
{ tag: tags.propertyName, class: "property" },
{ tag: tags.variableName, class: "variable" },
{ tag: tags.local(tags.variableName), class: "variable" },
{ tag: tags.special(tags.variableName), class: "variable" },
{ tag: tags.operator, class: "operator" },
{ tag: tags.punctuation, class: "punctuation" },
{ tag: tags.bracket, class: "punctuation" },
{ tag: tags.separator, class: "punctuation" },
{ tag: tags.regexp, class: "regexp" },
{ tag: tags.escape, class: "escape" },
{ tag: tags.meta, class: "meta" },
{ tag: tags.heading, class: "heading" },
{ tag: tags.link, class: "link" },
{ tag: tags.url, class: "link" },
]);
import { staticSyntaxHighlighter } from "./syntax-roles.js";
export function highlightCode(code: string, filename: string): HighlightToken[][] {
const parser = getParserForFile(filename);
@@ -64,7 +22,7 @@ export function highlightCode(code: string, filename: string): HighlightToken[][
// Build a map of character positions to styles
const styleMap: Array<HighlightStyle | null> = Array.from({ length: code.length }, () => null);
highlightTree(tree, highlighter, (from, to, classes) => {
highlightTree(tree, staticSyntaxHighlighter, (from, to, classes) => {
for (let i = from; i < to && i < styleMap.length; i++) {
styleMap[i] = classes as HighlightStyle;
}