Skip to content

v1.6.3

Latest

Choose a tag to compare

@github-actions github-actions released this 24 Sep 08:16

MarkText Plus v1.6.3

Release notes. English is the default language; the Chinese section follows.

English

A long version, and its two ends are worth reading together. It opens with a
run of guards that each caught the shape of one failure rather than the rule
that failure broke — and it closes with three things nobody was measuring at
all: why closing the window felt slow, why opening a second document did, and
what happens when something throws where no code was watching.

The version number the editor sends out was frozen at 1.6.0

Every plugin-marketplace search identifies this editor to GitHub with a user
agent string. That string was typed out by hand, and the release process — which
carefully updates the version in two files — had never heard of it. It said
1.6.0 while the app shipped 1.6.2.

There was already a guard against exactly this. It had been added after the
About box spent five releases claiming to be v1.0.1. But it looked for a quote
sitting directly against a version number, which is what 'v1.0.1' looks like,
and 'MarkTextPlus/1.6.0' has a word in front of the number. The guard now
looks for a version anywhere inside a quoted string, and takes care not to
mistake an address like 127.0.0.1 for one.

A request that could never end would not have been noticed

After an AI stream left the editor spinning for fifteen minutes, a check was
added: count the requests a file opens, count the waits it bounds, and fail if
there are more of the first. It examined only files that construct an
HttpClient and counted only calls named getUrl, postUrl and so on.

package:http does neither — it opens its client out of sight and names its
methods get and post. So the update check, the one file the guard's own
comment holds up as the example that got this right, was never read by it at
all. An unbounded request could be added there and every test stayed green.
Both the gate and the counting now know about that library.

The editor can replace itself with a build CI made

control takes two new actions. update_app fetches a build — from a
published release, or from the package CI already makes for every push —
checks it against the SHA-256 GitHub publishes, and hands it to the installer;
the editor closes and comes back. install_plugin is the same thing for a
plugin, along the path the reader's own Install button takes.

The repository is a constant in the code rather than a parameter of the call:
"download something and run it" and "download this and run it" are different
powers, and only the second is needed. A build with no published SHA-256 is
refused rather than fetched — that is the one door standing between bytes off
the network and a program running on the machine. An older release is refused,
and so is an update while a document has unsaved work in it, since installing
closes the editor and what is in that tab would go with it.

Windows installs per-user now ← uninstall the old copy first

To %LocalAppData%\Programs\MarkText Plus rather than Program Files, so
neither installing nor updating needs administrator rights and neither raises
a UAC prompt. File associations, the Start Menu entry and the desktop shortcut
are unchanged.

If your current copy went into Program Files: the new installer cannot see
it — one records itself under HKLM and the other under HKCU — so it installs
fresh and the old one stays where it is. Remove it by hand, once. Every update
after that will leave you alone.

Updating a plugin no longer throws away what you configured

A plugin's settings are kept inside its own directory, and installing replaces
that directory wholesale, so every update wiped the endpoint, the key and the
target language and the plugin came back looking newly installed. It was
survivable while updating meant deliberately downloading a ZIP; install_plugin
makes updating routine, which is what turned this into a fix.

Markdown that came out wrong

Four things the parser read differently from what you wrote, each of which
could take a large part of a document with it:

  • A line reading ``` aa ``` is a code span. It was opening a code block
    that never closed, so everything below it became code.
  • A fence indented four columns opened a code block in the preview while the
    source pane went on colouring the lines inside it as ordinary markdown. Four
    columns of indentation is an indented code block; the two panes agree now.
  • A sentence that wrapped before a number — "…is / 14. The number of doors…" —
    was taken apart into a paragraph and a list numbered from fourteen. A
    numbered list interrupts a paragraph only when it is numbered 1, which is
    what GitHub does too.
  • A backslash inside a code span was eaten as an escape, so `\.` came
    out as . and `C:\temp\*.md` lost a separator. A code span is
    literal.

Adding italic to bold text no longer takes the bold away

Select the words inside **bold** — not the asterisks, just the words, which is
how most people reach for a format — and press Ctrl+I. You used to get
*bold*: one asterisk taken from each side, the bold gone, nothing saying so.
It nests now, ***bold***, and pressing Ctrl+I again takes the italic back off.

The same press across two bold paragraphs at once lost the bold in both. And
asking for subscript inside ~~struck~~ wrote three tildes, which at the start
of a line is a code fence — the paragraph and everything after it disappeared
into a code block. Three tildes are never written now: subscript and
strikethrough cannot be nested in this flavour, so the one you press takes the
other's place.

Which markers compose and which replace each other is one rule in one place,
asked by all three of the paths that used to answer it differently.

The source pane paints a nested run as one colour

***bold*** was painted as ***bold** in the bold colour followed by a plain
asterisk — the pane saying that last marker is not part of the emphasis, while
the pane beside it read all six. With Ctrl+I on bold text now writing that
shape, every nested run in a document carried a stray asterisk. It is one span
now, bold and italic, and ___bold___ with it.

Two panes no longer disagree about a run of three before a full stop

***bold.***after was tinted bold in the source pane and drawn as six literal
asterisks in the preview. The bold pattern matches ***bold.** out of that line,
and the flanking rule was asked about the two asterisks the pattern captured
rather than the three that are there — so the character after the "opening
delimiter" was another delimiter, and a run that can neither open nor close
looked like it could do both. The run is measured now, at both ends.

A Chinese sentence reaches this shape far more often, because 。 ends a
sentence where an English full stop would more often fall outside the words
being marked.

Pasting from the web no longer turns a paragraph into a code block

A <del> holding a <sub> — strikethrough around a subscript — was written as
~~~x~~~, and three tildes at the start of a line open a fenced code block. The
pasted paragraph went inside one, and so did whatever was written after it.

del was the only one of the five wrapping tags with no guard on what it was
wrapping, and the guard the other four use would not have caught this one: it
asked whether the text contains the marker, and ~x~ only touches it. Both
are asked now. When strikethrough and subscript cannot both be written — and in
this flavour they cannot — the inner one is kept, which is what the other four
tags have always done. <strong><em> still nests as ***x***, because a run of
three asterisks is exactly what it means.

Code pasted from the web keeps its backticks

A run of backticks ends at the next run of the same length, and the converter
always wrote one around an inline <code> and three around a <pre> without
looking at what was inside. So a JavaScript template literal copied off a page
came back in three pieces with the backticks it was quoting gone, and a code
block that itself contained a fence was split into a block, a paragraph and an
empty block. The delimiter is longer than anything inside it now.

A pasted table keeps its shape when a cell holds two lines

A row ends at a line ending, so a cell cannot hold one — and a <br> inside a
cell was written as one. <td>a<br>b</td><td>c</td> came back as a row holding
a and nothing, then a row holding b and c: every cell after the break moved
a column and the header stopped describing what was under it. Two breaks in one
cell lost the last two pieces outright. Separate paragraphs in a cell, which is
what a word processor puts on the clipboard, arrived with the words run together
as onetwo.

A break in a cell becomes a space now, and a block boundary becomes one too. GFM
writes the break as an inline <br>, which this editor reads only when HTML is
turned on and it is off by default — so that would have shown a tag where someone
wrote a line.

A pasted link is no longer cut short by its own address

A destination ends at the ) that closes it and a label at the ], and the
converter wrote both without asking what was inside. A link to an address holding
an unbalanced bracket came back pointing at the part before it, with the rest
leaking into the paragraph as text; an address holding a space stopped being a
link at all; and a label holding a ] — "see [1] here" — arrived as literal
characters with the address showing beside them. Images went the same way.

Addresses that need it are written between angle brackets, which the format
allows for exactly this, and brackets in a label are escaped. An address that
needs neither is left alone, so a balanced http://x/a(b)c still looks like
itself. A linked thumbnail stays an image: only the label's text is escaped, not
the markup inside it.

A pasted italic is no longer cut short by an asterisk in the text

An emphasis ends at the run that closes it, so <em>a*b</em> — written as
*a*b* — came back with the italic stopping at the reader's own asterisk and the
rest of it left as a stray character. Bold went the same way on a doubled one.

The asterisks in the text are escaped rather than the emphasis being dropped,
because dropping it is what the other wrapping tags do and it would cost more
than the bug here: italic around bold is an everyday shape and the markup for the
inner one is asterisks. Nothing is lost now, and a code span inside an emphasis
keeps its asterisks untouched — a backslash in code is a backslash.

Exported HTML reads back as the document it came from

Five things the export could write and the paste path could not read: a link's
title, inline maths, a maths block, a footnote reference and a footnote
definition. So a document exported to HTML and pasted back — or formatted text
copied between two MarkText windows — came back with its tooltips gone, its
formulas turned into the parentheses \(a+b\) reads as, and its footnotes split
into a superscript wrapped around a link, no longer joined to the note they named.

This had happened once before, to four other tags, and the fix then was the four
tags rather than a way of noticing. Now every kind of block and span needs either
a sample that survives the round trip or an exemption saying why it cannot, so a
new kind fails until somebody has decided which it is. Three are exempt, each
with its reason written down.

A picture pasted from a lazily loading page is the picture

Reading an attribute matched the end of a longer name: asking for src found
data-src, href found data-href and title found data-title, so which
value a paste used was decided by which attribute the page happened to write
first. The whole name has to match now.

On its own that would have been a step backwards for the web as it is, where a
lazily loaded image keeps a placeholder in src and its real address in a data
attribute. That fallback is a decision now instead of an accident of attribute
order, and it is only taken when src has nothing usable in it — so a picture
this editor inlined on its way out is left exactly as it was.

Copy as HTML hands over the editor's HTML

Four places turn a selection into HTML for the clipboard — Ctrl+C, Cut, the
menu's Copy, and the preview's copy — and all four parse the markdown and write
it out the way the export does. The one item named after HTML did not: it ran a
chain of regular expressions over the selected text, four inline forms and six
heading levels, and left everything else as it was.

So a list, a table, a link, an image, a code block, a quote, a formula, a
footnote, a highlight, an underline or a raised letter came out as the markdown
that made it; **加粗。**后面 came out bold where the preview draws asterisks;
and nothing was escaped, so a selection holding a < b produced HTML that no
longer said a < b. It uses the same conversion as the other four now.

A regular-expression search anchors to lines, and a replacement can put back what it found

^ and $ meant the start and end of the whole document, so ^#+ — the most
natural thing to type into a regular-expression search here, "find every heading"
— found the first heading only if the document opened with one, and nothing
otherwise. They anchor to lines now, as they do in every other editor. . still
does not cross a line.

And a replacement can name what the pattern captured: $1 through $99 for a
group, $& for the whole match, $$ for a literal dollar — the spelling every
other editor uses. So searching \[(.+?)\]\((.+?)\) and replacing with $2: $1
turns every link in the selection around, which is the one thing a
regular-expression replace is for. A group number the pattern does not have is
left as it stands rather than quietly becoming nothing, and a literal search still
replaces literally, so $5 stays $5.

The AI endpoint accepts the base URL the provider documents

Every provider writes its base URL with the version on the end — OpenAI's
https://api.openai.com/v1, Anthropic's https://api.anthropic.com/v1, and so
does every service that speaks the same protocol, from a local Ollama to
OpenRouter. That is what gets pasted into the endpoint field, and the version was
appended anyway: the request went to /v1/v1/chat/completions and came back a 404
whose body says nothing about a doubled path, so it read as a missing model or a
dead service.

Both spellings work now, with or without the /v1. The field's own advice — enter
the root, not the full request path — is true either way, so it has not changed.

One sentence that was English in every language

A plugin declaring no settings was told so in English — X has no settings. —
whatever language the rest of the window was in. It was the only one of the
editor's 403 strings written in the source rather than in the translation files,
and the kind of leak that only somebody reading in another language would notice.

A scan now looks at every place a sentence reaches the reader and fails on a
literal holding two or more running English words, so the next one fails a test
instead of shipping.

"You have not set the AI up yet" is said in your language, and names one field

Running an AI command before filling in the endpoint, the model and the key is the
first thing anybody meets, and the refusal was an English sentence — in an editor
running in Chinese, Japanese or Arabic. Both places that show it, the plugin
failure dialog and Settings' test button, printed the error exactly as it came.

It is translated now, and it names the one field that is missing instead of
listing three: a reader with only the key blank was being sent to check the
endpoint and the model as well. The field named is the first one missing in the
order they appear on screen, so somebody who has filled in nothing is sent to the
top of the form rather than the bottom.

A provider's own reply is still shown as it came. A 400 about a model that does not
exist or a key that has expired says far more than a sentence of ours could, and
rewriting it would take that away.

A diagram with a typo no longer explains itself in English inside your PDF

The Mermaid package cannot reach the editor's translations, so its own error box
is English by design and the app words the failure itself. The preview did that;
the export and the fullscreen view did not. So a document with one mistyped
diagram came out of the exporter with a red English panel baked into it — a PDF
the reader then sends to somebody else — and tapping a broken diagram to enlarge
it answered in English too.

All three draw the same box now. The diagram type names inside it stay as they
are, in every language, because they are what has to be typed.

Editing a large file no longer fills memory with undo history

Every undo step is a whole copy of the document, and the history was bounded at
two hundred steps. For a note that is a few megabytes of history; for a
one-megabyte document it is two hundred megabytes, and for a ten-megabyte one two
gigabytes — per tab, and again for redo. It was the largest thing in the process
and nothing measured it.

The history is bounded by how much text it holds now, as well as by how many
steps. Nothing changes for a document small enough that two hundred copies of it
are cheap, which is almost every Markdown file: everything under about eighty
kilobytes keeps all two hundred steps. Above that the oldest states are dropped
first, and at least one undo is always kept however large the document is.

Extending a selection through a large document stays smooth

Every selection change copied the whole selected text into the editor's state and
compared it against the one before it, while the three places that want it ask for
it at the moment a command runs. So holding Shift+Down through a large document
copied a progressively larger string on every keypress — the gesture as a whole
quadratic — and a four-megabyte selection then sat in memory until the next one,
beside the document, the text field's own copy and the undo history.

The selection is a range now, and the text is taken when somebody asks. Which pane
answers is unchanged: whichever one the reader touched last, so a plugin run from
the preview is not handed what the source pane had selected a minute ago.

Moving the caret in a large file is no longer slower than the file

Every caret move split the whole document into lines — twice. The Format menu
works out whether the table commands apply while it is being built, and it did
that by rebuilding the caret's offset from the line and column the status bar
shows, then handing the document to a table lookup that split it again. Over eight
megabytes that is 36.7 ms each, so an arrow key cost about seventy milliseconds
against a frame of 16.7, and holding one down stuttered.

The text field knows where the caret is, and whether the caret is in a table needs
only the line it is on: 0 µs on the same document. The menu still rebuilds when the
caret moves, because the commands grey out when it leaves a table — what it no
longer does is read the document to find out where it went.

One thing changed with it: in preview mode, where there is no text field, the table
commands are greyed out. They used to light up for a position built from whatever
the source pane last reported, which is not somewhere the reader can see.

The automation interface can save a tab

close_tab refuses a tab with unsaved work, because nothing on that side can
press Save — which left a caller that had written to a tab unable either to keep
what it wrote or to tidy the tab away. save_tab is the missing half, and it is
the half worth having: what an automated caller can be asked for is "keep this",
never "throw it away".

It writes the way Ctrl+S does, through the same method auto-save now uses, so the
checks cannot drift apart: the file must not have changed underneath, and the
encoding the write actually used is what the tab records afterwards.

Ctrl+Z takes back an edit made in the preview

The preview is not read-only — a checkbox can be ticked in it, a block edited in
place — and in preview-only mode Ctrl+Z did nothing at all afterwards. Every
undo snapshot in the editor was taken by the source pane, and preview-only mode
does not build one. In the split it was coarse instead of absent: one press
stepped back past however many boxes had been ticked since the source pane last
recorded anything.

Each edit made in the preview is now its own step back, in both modes.

A file deleted from under an open tab says so

Something else removing a file you have open — a checkout, a sync client, rm —
left the tab looking exactly as it had a moment before: no dot, no banner, the
path still in the status bar. Closing it then took the last copy of the document
with it, and neither the deletion nor the loss was ever mentioned.

The text is kept, which was already right, and the banner now says what happened:
changed on disk, auto-save paused. Of the three ways out of a conflict, Overwrite
is the one that puts the file back. Deleting a file yourself still closes its tab
— that is a different thing and was already handled. A file another program is
part-way through writing is briefly unreadable, and that is not reported, because
it is not gone.

The automation interface will not close a tab over your unsaved work

Every way a person closes a tab asks first — the tab bar's button, the File menu,
the side bar, and the window's own close button, which lists what is unsaved and
abandons the quit if a save is abandoned. close_tab over the automation socket
was the one way that did not: it closed the tab, let the undo history go with it,
and answered "closed tab". It now refuses and names the tab, which is what
update_app in the same switch has always done, for the reason it gives — there
is nothing on this side that can press Save.

A tab with no file behind it is not an exception: auto-save skips those entirely,
so what is in one exists nowhere else.

Exporting Word over a file you already have cannot destroy it

The picker asks whether to replace, so exporting over an earlier .docx is an
ordinary thing to do — and the write truncated that file the moment it opened
it. A failure after that left nothing behind: a full disk, no permission, or, on
Windows, the same document still open in Word, which locks it.

HTML and PDF have been written through a scratch file and swapped into place for
a while. Word's write was inside the package that builds the document, where a
search of this repository does not find it. It goes through the same path now.

The encoding shown is the encoding written

A document read as Latin-1 or GBK, with a character that encoding cannot carry
added to it, is written as UTF-8 — the alternative is losing those characters.
The status bar went on naming the old one, and the "read it again as…" menu
beside it would then decode a UTF-8 file as Latin-1 and hand back mojibake, at
the reader's own request.

Auto-save had taken the answer the write gives back; Ctrl+S, Save As and the
overwrite chosen out of a conflict all threw it away. Recording what was written
is now part of recording that a tab was saved, and the compiler will not let a
fifth way to save leave it out.

A file that cannot be read says so, however you opened it

Drop a .md the editor cannot read — no permission, a share that went away,
something deleting it between the drop and the read — and a tab appeared, span
for a moment and vanished, with nothing on screen to say why. Double-clicking
one in the file manager was the same: the editor started, showed nothing, and
explained nothing.

Opening through the sidebar, the File menu and Open Recent have all reported
this for a long time. Dropping and being handed a file on the command line were
the two copies that had not caught up — the comment on one of them ended "or
show error state", a choice never made. Both now say it, and the other files in
a multi-file drop still open.

Icons that point somewhere point the way you read

In Arabic the file tree indents to the left, and the arrow on a collapsed folder
pointed right — away from where it opens. Two more: the chevron marking the
selected settings category pointed at the edge of the window rather than at the
panel, and the send button's paper plane pointed back the way you came.

The tree's indentation had been direction-aware for a while; the arrow drawn
inside it had not. All three now mirror, and three title bars whose padding put
the wider margin on the wrong side mirror with them.

Rereading a file in another encoding is a way out of a conflict again

When something else rewrites a file you have open, the status bar says so and
offers three ways out: reload, overwrite, or read it again in an encoding you
pick. The third put the banner away and left the baseline describing the file as
it was before the rewrite — so the next save raised the same conflict, over a
change already sitting in your tab. It now records what it read.

Underneath both: that baseline was taken after the bytes rather than before
them, so a write landing between the two was recorded as already seen and the
next save went over it without asking. The comment beside the code argued for
the other order; the code has been brought round to it. Two reading and writing
helpers that nothing used — one of which truncated the file it opened — are
gone, so the unsafe version is no longer the one found first.

Jumping to a line goes to that line, and typewriter mode works at all

Six things ask the editing pane to go to a line: the outline, the sidebar's two
search lists, a click in the preview, and the find bar when the preview is the
target. The pane turned the line number into a pixel by multiplying by the line
height, which is short by a line for every long line that wrapped above it —
asking for line 20 of a document of long paragraphs left it 1497 pixels below
the bottom of the window.

Typewriter mode had the same sum in it, and something worse: the line it centred
was jumped back to the nearest edge a frame later, by the code that keeps the
caret on screen when the pane scrolls. Whatever it animated to, the caret ended
up against the bottom edge. The two now take turns instead of fighting, and both
wait for the text to be laid out before asking where anything is.

The formatting strip appears over the text it belongs to

Its horizontal position was measured against the font; its vertical position
was worked out as line * lineHeight, corrected for the scroll by hand. Neither
is what the pane draws: a long line in a narrow split pane wraps into several
visual ones, the line height rounds to a whole pixel, and the scroll correction
did not match. Three wrapped lines above the selection put the strip 317 pixels
too high; on line 550 of a 600 line document it left the screen entirely.

Both coordinates now come from the field that is drawing the text.

Find Next in a large file no longer freezes the editor

Jumping to a match needed the pixel the match had been drawn at, so that it could
be scrolled a third of the way down — and the line number alone will not do, since
in split view a long line wraps into several visual ones. To get that pixel the
editor laid the whole run of text before the match out a second time: 532 ms at one
megabyte, 2.3 seconds at four, for every press. Walking twenty matches meant nearly
a minute of a frozen window.

The pane is already drawing that text. The position is now read off it, which takes
46 microseconds and accounts for wrapping because it is the wrapping. On top of
that, every press used to count the lines before the match by cutting the document
there and splitting the piece into lines — 55 000 strings on a four megabyte
document — for a number only the fallback path ever wanted.

An agent can put the editor into the state it needs to check

The automation interface could open documents, write into them, save them and
run plugins, and could not change a setting — so every change that shows up as
an appearance could only be verified by asking a person to open the settings
page. set_setting does that now, by name.

Not everything: credentials and where a credential is sent, the connection the
request arrived on, the records of what happened, the numbers the window manager
writes as the window moves, and the one setting set_view_mode already changes,
are all refused, each with a sentence saying which it was. A value of the wrong
kind is refused too, and nothing is written when it is — the first version of
this wrote the default first and then reported the refusal, which changed the
reader's font size on the way to saying it would not.

You can choose the font the preview reads in

There was one font setting and it belonged to the editing pane, which shows
markup and defaults to a monospace face so a table's pipes line up. The preview
— where a document is actually read — drew prose in whatever the platform
supplied, and nothing could change it. Three of the twelve translations called
that one setting "body text font", which is the half it did not do.

Preview Font Family is its own row now, empty by default, so nothing changes
unless you ask for something. Headings, paragraphs, lists, tables and quotes all
follow it; code keeps the code font, which is the point of having two. A face
your system does not have falls back rather than drawing boxes. The editing
pane's row is unchanged, and says "editor" in every language now rather than
"body text" in three of them.

Two commands in a row are two presses of undo

The editor closes an undo step 300 ms after a pause in typing, and a command —
bold, a heading, an indent, duplicating a line, moving a block — left the
boundary to that. So two commands quicker than the pause arrived as one entry
holding only the last state: a single Ctrl+Z took back both, along with anything
typed in the same window. Twenty-five writes were like that; two were not, which
is where the fix came from.

Typing is unchanged on purpose. Auto-pairing a bracket, closing a list on Enter,
deleting the other half of a pair — those are keystrokes, and giving each its own
step would make undo character-by-character.

An agent can answer the "unsaved changes" question

Closing a tab that holds unsaved work asks one of three things: Cancel, Don't
save, Save. The automation interface could give two of them — Save by writing
the file first, Cancel by not asking — and not the third, so it refused
outright and a scratch tab it had opened itself could only be closed by
somebody at the keyboard.

close_tab now takes discard: true, which is that third answer spelt the way
the dialog spells it. Refusing stays the default, for the reason it always gave:
closing a modified tab takes its undo history with it, so there is nothing left
afterwards to take the decision back with. The refusal now names both ways out,
and a discard says how many characters went with it — the only record it leaves.

You can turn off the check for new versions

It was the one thing this editor did on the network without being asked, and the
one you could not stop. The automation port is off until you open it; a plugin's
browser is behind a permission and its every host is logged; exported HTML
carries no link but the maths one. The update check went to GitHub after the
first frame of every launch a day apart, and the settings that mentioned it —
when it last ran, which version to stop mentioning — recorded that it had
happened rather than whether it should.

Settings ▸ General now has a switch, on by default, so nothing changes unless
you ask. Help ▸ Check for updates still works when it is off: what the switch
governs is the one nobody asked for. A clock that has moved backwards no longer
skips the check either — a timestamp from the future is one to ignore, not one to
trust.

The Edit menu's Paste keeps what the keyboard's Paste keeps

Ctrl+V reads both flavours of the clipboard and replaces what landed with the
HTML converted to Markdown — so a page copied out of a browser arrives with its
headings and lists. The Edit menu's Paste read the plain flavour and wrote it
straight in, so the same page arrived as a wall of text. It also pasted a web
address over selected words as an address rather than as a link, and neither it
nor Cut left anything for Ctrl+Z to come back to.

Both now go through the editor, where that one implementation already lives, so
there is one paste rather than two. Cut publishes the rich flavour the way Copy
does, and both are one press of undo. They are also searchable in the command
palette, which offers every other editing command.

The status bar no longer goes striped over a large document

"Syntax highlighting off" appears for a document past the size the highlighter
gives up at — and its width had never been counted, because the check that keeps
the bar from overflowing pumps a bar with no document open, where that line is
never shown. So a 200 KB file striped the bar at 1200 pixels. The line is
measured now, in whichever of the twelve languages it is written in, and the
least useful counts stand down sooner to make room for it; below a width where
even the word count has to fit around it, the explanation stands down too.

It is also no longer said in preview-only mode, which builds no source editor at
all: nothing was coloured there, so nothing was taken away.

Replace is one undo, and so is Replace All

Both buttons write through the same path typing takes, and that path records
history 300 ms after a pause — so a run of replacements faster than that arrived
as a single entry, and only the last state. Pressing Replace ten times and then
Ctrl+Z took back all ten; replacing one term everywhere and then another took
both back at once. Pressing Replace over and over is how you walk a document,
which is exactly when that window is open.

An edit an agent made over the automation interface can be taken back too. It
was the one writer of a document that recorded nothing to step back to, so
Ctrl+Z either did nothing or stepped past it to whatever you last typed.

An untitled document you emptied closes without asking

Typing into a new tab and then deleting it all left the tab counted as unsaved
work, so closing it asked whether to save something that was not there. Every
other editor closes that one quietly. A document that has a file behind it is
unchanged: emptying one of those is an edit, and is still treated as one.

Clicking the end of a long document's outline goes there

While a long document is still filling in, the preview knew how many blocks had
been asked for and took that for how many were on screen — the blocks, and so
the headings a jump aims at, only appear in the frame after. A jump arriving in
that gap settled for the last heading that really had been drawn, which can be
thousands of lines short, and threw the request away, so nothing ever corrected
it. At a megabyte that window was the fourteen seconds the fill took.

A large document's first paint no longer cuts a block in half

A document over 1500 lines is shown in two passes, the top of it first. That
first pass could stop inside a <pre> or a $$ … $$ block, which then
swallowed everything after it until the whole document arrived.

The plugin marketplace speaks your language when it fails

"could not reach GitHub; check the network or a proxy" was English in all
twelve languages — in red, at the moment you most need to understand it. The
two failures you can act on, no network and GitHub asking you to wait, are
translated now, with the seconds.

Right to left

A quote's accent bar stood on the left in Arabic, across the quote from where
the words start, and the rule between the line numbers and the code stayed on
one side while the numbers moved.

Smaller

  • The explanation of why the About box's version broke was attached to the undo
    and redo method rather than to the About box, where the next person to touch
    it would read it.
  • The check that every icon-only button carries a tooltip could not see
    Material 3's named constructors, so an IconButton.filled without one would
    have shipped unannounced.
  • Setting the view mode over the automation interface said it had happened
    before it had, so an agent asking for the state in the next breath could be
    shown the old one.
  • How long each step of starting up took can now be read over the automation
    interface. The log carried one number — "+901 ms before Dart" — and loading
    the executable, booting the engine and reading the snapshot are three
    different problems with three different answers.
  • Saving a tab over the automation interface and giving it a file at the same
    time answered with the name the tab had before, not the name of the file it
    had just written — the only case where the two differ, and the case the
    caller most needs answered.
  • The automation interface answered in two languages: twenty-two of its
    refusals were Chinese where everything else it says is English, and five of
    those said only "the same as above" — which is nothing at all when they are
    delivered one at a time.
  • Asked to close a pane without saying which, it replied unknown slot "null",
    quoting back a value the caller never sent. Missing and wrong are different
    answers, and both now name the slots there are.
  • The automation tool's own description named nine things it could do where
    there are thirteen, leaving out saving a tab, taking a close back, opening a
    panel and changing a setting. That paragraph is the first thing read to
    decide whether the tool is the one wanted, so it now reads its list off the
    actions instead of carrying a third hand-written copy of them.
  • Three of its seventeen arguments said nothing about themselves, and one of
    those was the one that needed it: the panes are named after quarters of the
    tab rather than edges of it, so "bottom" is the bottom left one and
    nothing in the protocol said so.
  • Setting the view mode over the interface had the same fault the pane one had
    an hour earlier — unknown mode "null" for a value nobody sent, and no word
    on which modes there are. All three places that take a value from a fixed
    set now answer the same way, and the set is read off the values themselves.

The side bar remembers your files again

Open a document, close the window, then open a different one, and the side bar
had forgotten the first. The list was not failing to come back — it was being
written over before it was read. A launch that carries a document opened that
document first, and registering it saved the side bar's list as "just this one
file", so the restore a moment later read exactly what it had destroyed.

It now reads the list before anything can write it, refuses to write it before
it has been read, and merges rather than replaces — so the order of those two
cannot be got wrong again.

Switching documents and panes got much faster

Opening a second file stuttered, and so did closing the window. Measured with a
117 KB document open beside a small one: every switch redrew the whole document
from scratch, 190-260 ms each time, and two of those redraws ran in the same
frame — both documents painting at once. One switch took 3.3 seconds.

Two causes, one line apart. The stack that holds the source, preview and split
panes was keyed on the mode as well as the document, so changing mode threw all
three panes away and rebuilt them — the exact thing the stack was there to
avoid. And it sat inside a 150 ms cross-fade, which is why two documents were
painting at once, at the moment you are waiting for the switch to finish.

The window closing slowly was the same fault seen from another side: closing
itself takes 20-35 ms, but the click has to reach a thread that was busy
rebuilding a document.

Edit → Undo no longer loses what you just typed

Ctrl+Z and the Edit menu's Undo went through different code. The keystroke let
undo read the text field; the menu handed it the tab's copy instead — and that
copy is written on a 300 ms debounce, so while you are typing it is behind the
field, and further behind while a large document is being redrawn.

Undo puts whatever it is told is "now" onto the redo stack before stepping
back. Given the stale copy, the characters typed since the last pause went off
the screen and onto nothing: redo could not bring them back. Type a few letters
and reach straight for the menu and they were gone.

The tab's copy is still what preview mode uses, because there is no field
there. It is simply no longer used when there is one.

The automation interface can work on the document

format runs any of the editor's own formatting commands — the same path the
Format menu and the keyboard take. undo and redo step the same history the
Edit menu steps. set_clipboard puts text on the clipboard, and HTML beside it
the way a browser does, which is the flavour this editor's paste reads first.

The refusals matter more than the commands. A format command is a request that
a pane picks up on its next frame, so this waits until one has, and says what
it did to the document. In the preview with no block open nothing would pick it
up, so it is refused with what to do instead — and the request is dropped
rather than left to fire the moment a pane appears, which would be an edit
nobody asked for at a time nobody chose.

set_clipboard replaces what is on the reader's clipboard. It says so.

The window can be driven from outside

set_window maximises, minimises, goes full screen, returns to normal, and
sets a size. The answer reports what the window became rather than what was
asked for: a window manager clamps a size to the work area and to the window's
own minimum, so those are two different numbers. It will not make the window
smaller than a window whose title bar can still be grabbed.

This was asked for from the beginning and never built, and it is what stood
between a machine and the rest of the checks: two of them are "drag the window
from 1200 to 700 to 400 and look for stripes". Taking the screenshot was
already possible; moving the window was not.

Reopen a closed tab

Ctrl+Alt+R, or File → Reopen Closed Tab, opens the document you just closed —
back in the position it held, not at the end. Every editor with tabs has this
and this one did not: the file had to be found again in the sidebar, or in
Recent Files if it was still there, or typed into the open dialog.

Not Ctrl+Shift+T, which browsers and VS Code use, because that key is the task
list here and has been since upstream. It is in the command palette and in the
shortcut list, so it can be rebound to whatever you like.

The path is what is kept, not the text — holding the contents of the last ten
closed documents would cost more memory than this editor is willing to spend —
so what comes back is the file as it stands on disk. A tab that was never
saved has no path and is not offered; closing a modified one asks first, so
answering "don't save" is a decision rather than a slip.

The automation interface gained reopen_tab for the same reason: closing is
the one thing it could do that destroys something, and it could not take it
back.

The editor could not say which editor it was

Asked over the automation interface, every shipped build introduced itself as
"dev". The version it reported came from a compile-time setting named
APP_VERSION, which appears exactly once in this repository — in the line that
reads it. Nothing had ever defined it, so the fallback was the only answer
there had ever been.

get_state now carries the version too. After the editor has replaced itself
with a newer build and come back, what came back is the thing worth knowing,
and the handshake is read once at connect time and not offered again.

A released build can say which build it is

The startup trace prints a line naming the commit it was built from. The
workflow that builds the binaries nobody ships passed it; the workflow that
builds the ones on the Releases page did not, on all three platforms — so the
downloads said "this is not a CI build" about a build CI made. It exists
because a slow-launch report was once diagnosed against source several commits
newer than the binary that produced it, which is exactly the report it was
silent for.

Closing the window now closes the window

A reader reported for the third time that closing the editor was slow, and
every measurement the editor could take said it was fast: seventeen to
thirty-five milliseconds from being told about the close to the window going,
in every recorded run, and a watchdog around the shutdown that had never
written a line.

The measurements were of the wrong stretch, and nothing measured the right one.
So the runner took its own: the click arriving, the window leaving the screen,
and the last instruction the process runs. On a reader's machine the click was
heard in 0 ms and the last instruction came 128 ms later — and the window had
never left the screen at all. That was not a failed measurement. It was the
answer:

void WindowManager::Destroy() { PostQuitMessage(0); }

Closing does not destroy this window. It asks the message loop to stop, and the
window stands in front of the reader until the process itself dies — through
everything Windows does to unmap a fifty-megabyte install, running the detach
handler of every library it loaded. Meanwhile the editor's own trace said
"window destroyed", because that line was written after the call returned.

The window is now taken off the screen at once, and the process ends at once
rather than being wound down. That second half is not decoration. A reader
asked what happens if they close the editor and immediately open a document,
and the answer was: nothing, silently. For those seconds the dying process
still holds the single-instance lock and the pipe a second launch hands its
path to, while nothing is left alive to read them — so the document was passed
to a dead listener and the launch quit. Making the window vanish is precisely
what would have invited them to try.

The window came back somewhere you could not find it

Closing the editor while it was minimized stored where the window was. A
minimized window is not anywhere: Windows reports the corner it parks them in,
far off every screen, at a size of a few dozen pixels, and that was written
down as the window's place. The next launch opened there.

It was an update that did the closing, with the window minimized at the time.
The geometry of a window that is nowhere is now left alone — what was stored is
where the window last was, which is what the record is for — and the startup
trace prints both what it read and what it decided, because working out which
of those had gone wrong cost a round trip through the reader.

Opening a second document no longer starts a second editor

Double-clicking a document while the editor was open took a second or more
before anything happened, and none of it was the document. The check for "am I
already running" lives in Dart, and Dart does not run until the engine has:
measured on a reader's machine, 462 ms for Windows to map the program and its
libraries, and some 600 ms more for the engine and its snapshot. A whole second
copy of the editor started up in order to pass one path along and quit.

The runner now asks that question before any of it, in the first instruction it
runs. Every way this can fail falls through to starting normally, which is what
happened before it existed.

The editor says when something breaks, and when a frame was slow

Nothing here reported a failure that somebody had not gone looking for. The
parser times itself, the preview times itself, startup times each of its
phases — and a throw while a widget builds painted a grey rectangle in a
release build and wrote nothing at all, while a throw from a future nobody
awaited went to a console a windowed program does not have. Both were invisible
in the log a reader can open, which is the log a slow or broken session is
diagnosed from.

Faults now reach it. Saying them is easy; not drowning the log in them is the
work, because a build that throws throws again on every frame afterwards. The
same fault is said once and then counted, and "the same" is deliberately the
kind of fault rather than its message — a message carrying an index or a path
differs every frame while the fault does not.

A stutter is the other thing that was never measured, for the same reason: it
is by definition the part nobody timed. The editor now notices frames slow
enough to be seen and says how long they took, once per run of them.

Uninstalling takes the folder with it

The program writes diagnostics beside its own executable while it runs. The
installer did not put them there, so the uninstaller did not know about them,
and one unfamiliar file is enough for the installation folder to be left
standing. Somebody who removes an editor and finds its folder still there is
entitled to wonder what else it left.

中文

到目前为止三条修复,其实是同一件事的三个侧面:守卫是照着作者眼前那一个坏掉的
实例写的,而不是照着被它破坏的规则写的。

编辑器对外报的版本号停在 1.6.0

插件市场每次搜索都会带一个 user-agent 告诉 GitHub 自己是谁。那个字符串是手写的,
而发版流程只盯着两个文件里的版本号,从来不知道还有第三处。应用是 1.6.2,它说 1.6.0。

这件事本来是有守卫的——「关于」对话框连着五个版本自称 v1.0.1 之后立的。
但它找的是「引号紧贴版本号」,因为 'v1.0.1' 就长那样;'MarkTextPlus/1.6.0'
版本号前面有字,就漏了。现在改成在任意引号字符串内部找版本号,同时避开
127.0.0.1 这类看着像版本号的地址。

一个永远结束不了的请求,它也看不见

AI 流让编辑器空转十五分钟之后,立了一条规矩:数一数每个文件发出多少请求、
限住多少次等待,少了就红。但它只看构造了 HttpClient 的文件,只数
getUrl / postUrl 这类名字。

package:http 两条都不占——它的客户端开在看不见的地方,方法就叫 get、post。
于是更新检查,守卫注释里被当作正面例子引用的那个文件,从来没被它读过。
往那里加一个没有上限的请求,所有测试照样全绿。现在门槛和计数都认得这个库了。

编辑器可以自己更新自己了

control 新增两个动作。update_app 取一个构建——来自已发布的 release,或来自
CI 为每次推送本来就打好的包——比对 GitHub 公布的 SHA-256,然后交给安装器;
编辑器关闭,再自行回来。install_plugin 是同一件事的插件版,走的是读者点
「安装」那条一模一样的路。

仓库是代码里的常量而不是调用方给的参数——「下载一个东西并运行它」和「下载这一个
东西并运行它」是两种权力,只需要后者。没有公布 sha256 的构建直接拒绝:那是唯一一道
挡在「网络上来的字节」和「机器上运行的程序」之间的门。比当前旧的 release 会被拒绝;
有未保存内容时也会被拒绝——安装要关掉编辑器,那个标签页里的东西会跟着一起没。

Windows 安装包改为按用户安装 ← 升级前请先卸载旧版

装到 %LocalAppData%\Programs\MarkText Plus 而不是 Program Files,安装与更新都
不再需要管理员权限,也就不再弹 UAC。文件关联、开始菜单项、桌面快捷方式照旧。

如果你之前装的是 Program Files 版本:新安装器看不见它(两者的卸载信息一个在
HKLM、一个在 HKCU),会当作全新安装,旧的那份会留在原地。请手动卸载一次旧版。
这是一次性的,之后所有更新都不会再打扰你。

更新插件不再清空你填过的设置

插件的设置存在它自己的目录里,而安装是整目录替换——所以每更新一次,端点、密钥、
目标语言全都没了,插件回来时像是刚装上的。以前更新意味着有人专门去下一个 ZIP,
一年碰不到一次;install_plugin 让更新成了常规动作,这才把它从「能忍」变成「必须修」。

解析错了的 Markdown

四处解析与你写的不一致,每一处都可能带走文档的一大片:

  • 一行 ``` aa ``` 本是行内代码,却开启了一个永不闭合的代码块,
    它下面的全部内容都变成了代码。
  • 缩进四列的围栏在预览里开了代码块,源码区却照常把里面的行染成普通标记。
    缩进四列是缩进代码块——两个窗格现在说法一致。
  • 在「数字.」前换行的句子被拆成一个段落加一个从十四开始的列表。
    有序列表只有编号为 1 时才能打断段落,GitHub 也是这样。
  • 代码跨度里的反斜杠被当成转义吃掉:`\.` 显示成 .,
    `C:\temp\*.md` 少一个分隔符。代码跨度是字面的。

给粗体加斜体不再把粗体删掉

选中 **加粗** 里面的两个字——不选星号,只选字,这是大多数人加格式的方式——
按 Ctrl+I。以前会得到 *加粗*:两边各拿掉一个星号,粗体没了,也没有任何提示。
现在会嵌套成 ***加粗***,再按一次 Ctrl+I 只取消斜体。

同一个按键作用于两段各自加粗的段落时,两段的粗体会一起消失。而在
~~删除线~~ 里要下标会写出三个波浪号——行首三个波浪号是代码围栏,
这一段连同后面的全部内容都会掉进代码块里。现在绝不会写出三个波浪号:
下标与删除线在本方言里无法嵌套,所以你按下的那一个取代另一个。

哪些标记会叠、哪些互相取代,现在是一处的一条规则,从前各自给出不同答案的
三条路径都来问它。

源码区把嵌套的强调染成同一个颜色

***加粗*** 以前被染成 ***加粗**(加粗色)加一个普通色的星号——窗格在说
最后那个标记不属于这段强调,而旁边的窗格读到的是全部六个。既然 Ctrl+I 作用于
粗体现在就会写出这个形状,文档里每一处嵌套强调都会拖着一个落单的星号。
现在是一段,同时是粗体和斜体,___加粗___ 也一样。

两个窗格不再对 ***加粗。***后面 各说一套

源码窗格把这一行染成加粗色,预览画的是字面的星号。加粗模式从里面匹配出
***加粗。**,而贴合规则被问的是它捕获的那两个星号、不是实际存在的三个——
于是「开标记后面」答出来是另一个标记,这个运行看上去既能开又能闭。现在运行是
量出来的。中文句子以 。 收尾的频率远高于英文句号出现在被标记的词里,
所以这个形状每天都会遇到。

从网页粘贴不再把一个段落变成代码块

<del> 里套 <sub>——删除线里面套下标——以前写出 ~~~x~~~,而行首三个波浪号
开启一个代码围栏。粘贴进来的这一段掉进代码块,接着写的文字也一起进去。

del 是五个包裹类标签里唯一没有守卫的,而另外四个用的那道守卫也挡不住这一种:
它问的是文本含不含该标记,而 ~x~ 只是贴着它。现在两件都问。
删除线与下标无法同时写出时——在本方言里就是无法——保住里面那个,
这是另外四个标签一直以来的约定。<strong><em> 照旧嵌套成 ***x***,
因为三个星号一串正是它的意思。

从网页粘贴的代码保住它的反引号

一段反引号在遇到同样长度的下一段时结束,而转换器从不看内容里有几个——内联一律
写一个,代码块一律写三个。于是从网页复制的 JavaScript 模板字符串回来时断成三截、
它引用的反引号全丢,而本身含有围栏的代码块被拆成一个代码块、一个段落和一个空代码块。
现在分隔符总比内部任何一段更长。

粘贴的表格在单元格有两行时仍保持形状

表格的一行在换行处结束,所以单元格里不能有换行——而单元格里的 <br> 正是写成了
换行。<td>a<br>b</td><td>c</td> 回来时变成「a」「(空)」一行、「b」「c」一行:
换行之后的每个单元格都挪了一列,表头也不再对应下面的内容。一个单元格里两个换行,
后两段直接丢失。而单元格里的多个段落——文字处理软件放到剪贴板上就是这个形状——
回来时词被粘成 onetwo。

现在单元格里的换行变成一个空格,块与块之间也是。GFM 的正规写法是内联 <br>,
但这个编辑器只在 HTML 开关打开时读它,而默认是关的——那样会让写了一个换行的人
看到一个标签。

粘贴的链接不再被自己的网址截断

地址在闭合它的那个 ) 处结束,标签在 ] 处结束,而转换器写这两者时从不问内容里
有什么。网址里有不成对括号的链接,回来时只指向括号之前那一截,剩下的漏进正文;
网址里有空格的干脆不再是链接;链接文字里有 ] 的(比如「see [1] here」)
变成一串字面字符,网址还露在旁边。图片同理。

需要的时候地址用角括号包起来——格式本来就为这件事准备了它——标签里的方括号转义。
不需要时原样不动,所以成对的 http://x/a(b)c 看起来还是它本来的样子。
带链接的缩略图仍是图片:只转义标签里的文字,不动里面的标记。

粘贴的斜体不再被文字里的星号截断

强调在闭合它的那段运行处结束,所以 <em>a*b</em>——写成 *a*b*——回来时斜体停在
读者自己的那个星号上,后面剩下一个孤零零的字符。粗体在双星号上同样如此。

现在是把文字里的星号转义,而不是丢掉这一层强调:丢掉是其他包裹类标签的做法,
在这里代价比原缺陷更大——斜体里套粗体是每天都有的形状,而内层的标记正是星号。
现在什么都不丢,强调里的代码跨度也原样保留它的星号——代码里的反斜杠就是反斜杠。

导出的 HTML 粘贴回来仍是原来那篇文档

导出写得出而粘贴读不回的五样:链接的提示文字、行内公式、公式块、脚注引用、脚注定义。
于是一篇导出成 HTML 再粘回来的文档——或者在两个 MarkText 窗口之间复制格式化内容——
提示没了,公式变成 \(a+b\) 被读成的那对括号,脚注拆成上标套链接、
不再连着它指的那条注。

这件事发生过一次,当时是另外四个标签,而那次的修法是补那四个标签,
不是建立一种「会发现」的机制。现在每一种块与每一种内联要么有一条能通过往返的样本,
要么有一条写明理由的豁免,新增一种就会红到有人做出决定为止。三种是豁免,各有理由。

从懒加载网页粘来的图片就是那张图片

读属性时会匹配到更长名字的尾部:问 src 找到了 data-src,问 href 找到 data-href,
问 title 找到 data-title——取到哪个值由页面先写了哪个决定。现在必须整名匹配。

单这一条对现实中的网页是退步:懒加载的图片把占位符放在 src、真地址放在 data 属性里。
那个回退现在是一个决定,而不是属性顺序的巧合,并且只在 src 没有可用内容时才走——
所以编辑器自己导出时内嵌的图片原样保留。

「复制为 HTML」交出的是这个编辑器的 HTML

有四处把选区转成剪贴板上的 HTML——Ctrl+C、剪切、菜单的「复制」、预览自己的复制——
四处都是先解析 Markdown、再按导出的方式写出来。唯一一个名字里带 HTML 的菜单项
不是这样:它对选中的文本跑一串正则,四种内联加六级标题,其余一概原样留下。

于是列表、表格、链接、图片、代码块、引用、公式、脚注、高亮、下划线、上下标
都以写出它们的 Markdown 原样出现;**加粗。**后面 变成了粗体,而预览画的是
字面星号;而且一字不转义,所以含 a < b 的选区产出的 HTML 已经不再说 a < b。
现在它用与那四处相同的那一份转换。

正则查找按行锚定,替换可以放回它捕获到的东西

^ 与 $ 原先指的是整个文档的开头与结尾,所以 ^#+ ——在这里输入正则查找最自然的
一件事,「找出所有标题」——只在文档恰好以标题开头时找到第一个,否则一个也找不到。
现在它们按行锚定,和其他编辑器一样。. 仍然不跨行。

替换文本也可以指名模式捕获到的东西了:$1 到 $99 是分组,$& 是整个匹配,
$$ 是一个字面的美元号——所有其他编辑器用的就是这套拼法。于是查
\[(.+?)\]\((.+?)\)、替换为 $2: $1,选区里每个链接的文字与地址就都对调了,
而这正是正则替换唯一的用途。模式里没有的组号原样保留,不会悄悄变成空;
字面查找仍然字面替换,$5 还是 $5。

AI 端点接受供应商文档里给的那个 base URL

每家供应商写出的 base URL 都带版本段——OpenAI 的 https://api.openai.com/v1、
Anthropic 的 https://api.anthropic.com/v1,所有说同一套协议的服务也一样,
从本机的 Ollama 到 OpenRouter。粘进端点框里的就是它,而代码仍然会再追加一次版本段:
请求发到了 /v1/v1/chat/completions,回来一个 404,而响应体里不会提路径重复,
于是读起来像是「模型不存在」或「服务挂了」。

现在带不带 /v1 都能用。输入框自己那句提示——填根地址、不要填完整请求路径——
两种写法下都成立,所以没有改动。

一句在所有语言里都是英文的话

没有声明任何设置项的插件,其设置页会用英文告知——X has no settings.——
无论窗口其余部分是哪种语言。它是编辑器 403 条文案里唯一写在源码而不是翻译文件里的一条,
而这种泄漏只有用别的语言阅读的人才会注意到。

现在有一条扫描守卫,检查句子能到达读者的每一个位置,只要字面量里出现两个以上
连写的英文单词就失败——下一次泄漏会红在测试里,而不是发到读者手上。

「还没配好 AI」这句话会用你的语言说,并且只点出一个字段

还没填端点、模型和密钥就运行 AI 命令,是任何人都会先遇到的一步,而那句拒绝是英文的——
在一个界面为中文、日文或阿拉伯文的编辑器里。两个显示它的地方(插件失败对话框与设置页的
测试按钮)都原样打印了错误文本。

现在它被翻译了,而且只点出缺的那一个字段,不再列出三个:原先只有密钥为空的读者,
会被要求把端点和模型也检查一遍。点出的是按屏幕顺序第一个缺的,
所以三个都没填的人会被送到表单顶部,而不是底部。

供应商自己的回复仍然原样显示。一个「模型不存在」或「密钥已过期」的 400 响应,
说的比我们的句子多得多,改写它等于把这些信息拿走。

打错的图表不再在你的 PDF 里用英文解释自己

Mermaid 包够不到编辑器的翻译,所以它自带的错误框按设计是英文的,由应用自己措辞。
预览这样做了,导出和全屏查看没有。于是一份只有一处图表打错的文档,
导出后里面烙着一块英文红色面板——而那是读者要发给别人的 PDF;
点开那个坏图表放大,答复也是英文。

现在三处画的是同一个框。框里的图表类型名在任何语言下都保持原文,
因为它们是要照着打出来的东西。

编辑大文件不再让撤销历史占满内存

每一步撤销都是整份文档的副本,而历史的上限是两百步。对一篇笔记这是几 MB 的历史;
对一个 1 MB 的文档是 200 MB;对一个 10 MB 的文档是 2 GB——每个标签页一套,
重做还有一套。它是进程里最大的一块,而没有任何东西在量它。

现在历史同时受「保存了多少文字」和「多少步」两个上限约束。文档小到「两百份副本
很便宜」时行为完全不变,而这几乎是全部 Markdown 文件:约 80 KB 以下一步不少。
超过之后先丢最旧的状态,并且无论文档多大,至少保留一次撤销。

在大文档里扩展选区不再越选越卡

每次选区变化都会把整段选中的文字拷进编辑器状态、再与上一次的整串比较一遍,
而真正要用它的三个地方都是在命令运行的那一刻才去读。于是在大文档里按住 Shift+↓,
每一次按键都拷一个更大的字符串——整个手势是平方级的——而一个 4 MB 的选区随后
一直留在内存里,与文档本体、文本框自己那份、撤销历史并列。

现在选区是一个范围,文字在有人要的时候才取。哪个窗格答话的规则没有变:
读者最后动过的那个,所以从预览运行的插件不会拿到源码区一分钟前选的东西。

在大文件里移动光标不再比文件本身还慢

每次光标移动都会把整篇文档切成行——两次。格式菜单在构建时判断表格命令是否适用,
而它的做法是先用状态栏显示的行列重新算出光标偏移量,再把整篇文档交给表格查找、
又切一次。8 MB 文档下每次 36.7 ms,于是按一次方向键约七十毫秒,而一帧是 16.7 ms,
按住方向键就持续卡顿。

文本框本来就知道光标在哪;而「光标在表格里吗」只需要它所在的那一行——同一份文档上
0 µs。菜单仍然会在光标移动时重建,因为命令要随光标离开表格而置灰;
不再做的是重建时去读整篇文档。

随之改变的一件事:预览模式下没有文本框,表格命令现在置灰。以前它们会按源码窗格
最后报告的位置点亮,而那个位置读者在预览里看不见。

自动化接口可以保存标签页了

close_tab 会拒绝有未保存内容的标签页,因为那一端没有任何东西能按下保存——
于是一个写过内容的调用方既留不住它写的东西,也收拾不掉那个标签页。
save_tab 就是缺的那一半,而且是值得有的那一半:能向自动化调用方索取的显式决定
是「留下它」,不是「扔掉它」。

它按 Ctrl+S 的方式写,并且走的是自动保存现在也在走的那个方法,所以两者的检查不会各走各的:
文件必须没有在底下被改过,而真正用于写盘的编码就是标签页随后记下的那个。

Ctrl+Z 能撤回在预览里做的编辑

预览不是只读的——可以勾选复选框,也可以就地编辑一个块——而在纯预览模式下,
做完之后按 Ctrl+Z 毫无反应。编辑器里每一个撤销快照都由源码窗格记录,
而纯预览模式并不构建它。分屏下则是「有反应但不准」:一次按键会退回源码窗格上一次
记录之处,把此后勾的每一项一起撤掉。

现在预览里的每一次编辑都是独立的一步,两种模式都如此。

打开着的文件被别人删掉时会说出来

别的东西删掉你正打开的文件——git checkout、同步客户端、rm——标签页会毫无异样:
没有修改点、没有横幅、状态栏照旧显示那个路径。此时关掉它,文件和内容两头都没了,
而删除和丢失从头到尾没被提起过。

内容仍然留着(这一点本来就对),而横幅现在会说明发生了什么:磁盘上已改变,
自动保存已暂停。冲突的三条出路里,「覆盖」就是把文件写回去的那一条。
你自己删除文件时仍然会直接关掉它的标签页——那是另一件事,本来就处理好了。
别的程序写到一半的文件会短暂读不了,那种情况不会报,因为它并没有消失。

自动化接口不会带着你未保存的改动关掉标签页

每一条人关闭标签页的路都会先问——标签页上的 ×、文件菜单、侧边栏,
以及窗口自己的关闭按钮(它会列出未保存的内容,且放弃一次保存就放弃退出)。
只有自动化接口的 close_tab 不问:它关掉标签页、让撤销历史一起消失,
然后回答「closed tab」。现在它会拒绝并说出是哪一个——这正是同一个 switch 里
update_app 一直在做的事,理由也是它写下的那句:这一端没有任何东西能按下保存。

没有文件的标签页不算例外:自动保存完全跳过它们,里面的内容不存在于别处。

导出 Word 覆盖已有文件,不会再毁掉它

选择框会问「要替换吗」,所以覆盖上一份 .docx 是很平常的操作——而那次写入一打开
目标文件就把它截断
。此后一旦失败就什么都不剩:磁盘满、没有权限,或者在 Windows 上
那份文档仍开在 Word 里(它会加锁)。

HTML 与 PDF 早就改成「写临时文件再换过去」了。Word 的写盘在负责生成文档的那个包里,
在本仓库里搜不到。现在它走同一条路。

状态栏显示的编码,就是真正写盘的编码

一个按 Latin-1 或 GBK 读入的文档,加进了这种编码装不下的字符之后,会按 UTF-8
写盘
——否则那些字就丢了。而状态栏继续写着原来那个;接着从它旁边的「按…重新读取」
选回旧编码,就把一个 UTF-8 文件当 Latin-1 解码,读者亲手换来一屏乱码。

自动保存一直会接收写盘返回的那个答案;Ctrl+S、另存为、以及冲突里选「覆盖」
都把它丢掉了。现在「记录这个标签页已写盘」本身就包含「写的是哪种编码」,
而且编译器不会允许第五条保存路径漏掉它。

读不了的文件会说出来,无论你是怎么打开它的

把一个编辑器读不了的 .md 拖进窗口——没有权限、网络共享断开、拖放与读取之间被
删掉——标签页出现、转一下、消失,屏幕上没有任何说明。在文件管理器里双击一个
同样的文件也一样:应用起来了,什么都没有,也不说为什么。

从侧边栏、「文件 ▸ 打开」、「打开最近」打开时,这件事早就会说了。拖放和
命令行传入是没跟上的两份——其中一处的注释以「or show error state」结尾,
一个从没做完的选择。现在两处都会说,而一次拖入多个文件时,其余的照常打开。

指向某处的图标,现在指着你阅读的方向

阿拉伯语下文件树往左缩进,而折叠文件夹的箭头指右——背对它要展开的地方。
另有两处:设置里标记当前分类的箭头指向窗口边缘而不是内容面板,
发送按钮的纸飞机指着你读过来的方向。

文件树的缩进早就随方向镜像了,画在它里面的那个箭头没有。现在三处都会镜像;
另有三条标题栏的内边距把较宽的一侧放错了边,一并跟着镜像。

「按别的编码重读」重新成为一条走得通的出路

打开的文件被别的程序改写时,状态栏会说明,并给出三条出路:重新加载、覆盖、
或按你选的编码重新读取。第三条会把横幅收起来,却让基准继续描述改写之前的
文件——于是下一次保存又弹出同一个冲突,而冲突的内容正是你标签页里已经有的那份。
现在它会记下自己读到的东西。

两者底下还有一层:那个基准是在读完字节之后取的,而不是之前,所以落在两者之间
的写入会被记成「已经看过」,下一次保存不问一声就盖过去。代码旁边的注释主张的正是
另一种顺序,现在代码跟上了。另外删掉了两个没人用的读写辅助方法——其中一个一打开
文件就把它截断——这样先被找到的不再是不安全那半。

跳到某一行会真的跳到那一行,打字机模式也终于生效

有六个地方会让编辑窗格跳到某一行:大纲、侧栏的两个搜索列表、在预览里点击定位、
以及查找栏在以预览为目标时。窗格把行号乘以行高当作像素——上方每有一条换行的
长行就少算一行
。在长段落较多的文档里点大纲的第 20 行,那一行落在窗口下方
1497 像素
处。

打字机模式里是同一个乘法,还多一件更糟的:它居中之后,下一帧就被「把光标滚进
视野」的那段代码跳回最近边缘
。所以不管它动画到哪,光标最后都贴在底边——
这个模式从来没真正生效过。现在两者轮流而不是互相抵消,并且都等排版完成后
再去问位置。

格式工具条浮在它所属的那段文字上方

它的水平位置一直是按字体量出来的;垂直位置却是用「行号 × 行高」算出来、
再手工减去滚动量的。两者都不是窗格实际画的:分屏的窄窗格里一条长行会换成好几条
视觉行,行高会被取整到整像素,手工减的滚动量也对不上。选区上方只要有三条换行的
长行,工具条就偏高 317 像素;600 行文档的第 550 行上,它直接飘出屏幕。

现在两个坐标都从正在画这段文字的那个字段读。

在大文件里按「查找下一个」不再冻结编辑器

跳到一个匹配,需要知道它被画在哪个像素上,才能把它滚到视口三分之一处——
光有行号不够,因为分屏时一条长行会换行成好几条视觉行。而编辑器拿到那个像素的办法,
是把匹配之前的全部文字重新排版一遍:1 MB 上 532 ms,4 MB 上 2.3 秒,
每按一次都付。走完二十个匹配,窗口冻结将近一分钟。

那段文字本来就正由窗格画着。现在位置直接从它那里读,46 微秒,
并且天然算上换行——因为它就是换行本身。此外,每按一次还会先把文档在匹配处切开、
把前半截分成行来数行号(4 MB 上 5.5 万个字符串),而这个数只有兜底那条路用得上。

自动化接口可以把编辑器摆成要检查的那个样子

自动化接口能开文档、能写、能存、能跑插件,却改不了任何设置——于是凡是「看得见的
改动」都只能请人打开设置页来确认。现在有了 set_setting,按名字改。

不是什么都能改:凭据与它发往哪里、这次请求进来的那条连接、各种「记录」、
窗口移动时由窗口管理器写入的那些数字,以及 set_view_mode 已经在做的那一个,
全部拒绝,并且每一条都说得出自己属于哪一类。类型不对的值也拒绝,
而且拒绝时一个字都不写——这个功能的第一版是先写后校验,
于是它会先把读者的字号改回默认值,再告诉对方「这个值取不了」。

预览用什么字体读,可以自己选了

原先只有一个字体设置,它属于编辑窗格——那里显示的是标记,默认等宽,好让表格的
竖线对齐。而预览,也就是真正读文档的地方,用的是平台给什么就什么,谁都改不了。
十二种语言里有三种把这一个设置叫作「正文字体」,而正文恰恰是它不管的那一半。

现在**「预览字体」**是独立一行,默认留空,所以不主动去填就什么都不变。标题、段落、
列表、表格、引用都跟着它走,代码仍用代码字体——这正是分成两个设置的意义。
填了系统里没有的字体会回落,不会画成方框。编辑窗格那一行没有变化,
只是十二种语言现在一致地说「编辑器字体」,而不是其中三种说「正文字体」。

连做两个命令,就是按两次撤销

编辑器在停下打字 300 毫秒后才关上一个撤销步,而命令——加粗、标题、缩进、复制行、移动块
——把断步交给了它。于是比这更快的两个命令只会进栈一条、而且是最后那个状态:
一次 Ctrl+Z 把两个命令连同同一窗口里打的字一起退掉。这样的写入有 25 处;
另有 2 处不是这样,修法就是从那 2 处来的。

打字有意保持不变:自动配对括号、回车续列表、删掉配对的另一半——那些是按键,
每个按键一个撤销步会让撤销变成逐字。

代理现在能回答「未保存的更改」那个问题

关一个有未保存内容的标签页,会问三件事:取消、不保存、保存。自动化接口能给出其中两个
——「保存」是先写盘,「取消」是不问——第三个给不出,于是它只能直接拒绝,
而它自己开的草稿标签页只能由坐在键盘前的人来关。

close_tab 现在接受 discard: true,就是那个弹窗里「不保存」的那一下。
拒绝仍然是默认,理由没变:关掉一个改过的标签页会把它的撤销历史一起带走,
之后没有东西能把这个决定退回来。拒绝的话现在会把两条出路都说出来,
而真的丢弃时会说出丢了多少字符——那是它留下的唯一记录。

可以关掉「自动检查新版本」

这是这个编辑器唯一一个没被要求就发生的外连,也是唯一一个你关不掉的。
自动化端口默认关闭、要你主动开;插件的浏览器在权限后面,去过哪些主机都写进日志;
导出的 HTML 除了数学公式那一处零外链。而更新检查在每次启动的首帧之后就发往 GitHub
(相隔一天以上时),配置里提到它的那两项——上次什么时候查的、哪个版本别再提醒——
记的是「已经发生了」,而不是「该不该发生」。

设置 ▸ 通用现在有一个开关,默认开,所以不主动去关就什么都不变。
关掉之后「帮助 ▸ 立即检查更新」照旧可用——这个开关管的是没人要求的那一次。
另外,时钟倒退时不再跳过检查:来自未来的时间戳是该忽略的,不是该相信的。

编辑菜单的「粘贴」现在和键盘的粘贴一样

Ctrl+V 会读剪贴板的两种格式,把 HTML 转成 Markdown——所以从浏览器复制的网页带着标题和列表。
而编辑菜单里的「粘贴」只读纯文本直接写进去,同一段网页变成一坨没有结构的文字;
在选中的词上粘一个网址也只是贴个网址、不会变成链接;并且它和「剪切」都没有留下可撤销的还原点。

两者现在都走编辑器——那份唯一的实现本来就在那里——所以只有一种粘贴。
剪切像复制一样发布富文本格式,两者都是按一次撤销就回来。它们也能在命令面板里搜到了,
而命令面板本来就提供其他所有编辑命令。

打开大文档时状态栏不再变成黄黑条纹

「语法高亮已关闭」只在文档超过高亮器放弃的尺寸时出现,而它的宽度从没被算进去——
因为那条防止状态栏溢出的检查,pump 的是一个没有打开任何文档的 bar,那一格永远不显示。
于是一份 200 KB 的文件会让状态栏在 1200 像素就溢出。现在这句话的宽度是量出来的
(十二种语言各不相同),最没用的那几个计数会提前让位;而到了连字数都要绕着它排的宽度,
这句说明自己也会让位。

纯预览模式下也不再说这句话——那个模式压根不建源码编辑器,没有上过色,也就没有被拿走。

替换是一次撤销,全部替换也是

两个替换按钮走的是和打字相同的那条路,而那条路在停顿 300ms 之后才记录历史——
于是比这更快的一串替换只会进栈一条、而且是最后那个状态。连按 Replace 十次再 Ctrl+Z
会十处全退;先全部替换一个词、紧接着替换另一个,一次就把两轮都退掉。
而连着按 Replace 恰恰就是走一遍文档的用法,那个窗口正好开着。

代理通过自动化接口做的修改现在也能撤销了。 它是所有文档写入者里唯一没留还原点的,
所以按 Ctrl+Z 要么毫无反应,要么跨过它退回到你上次自己打的字。

删空的未命名文档关闭时不再追问

在新标签页里打几个字再全部删掉,它仍算「有未保存的工作」,按关闭会问要不要保存
一份并不存在的东西。其他编辑器都是直接关掉。有文件的文档不变——
把一份写过的文档删光是改动,照旧按改动对待。

长文档还在补画时点大纲,现在会到那一条

长文档还在逐屏填充时,预览把「已经要求画多少块」当成了「屏幕上已经有多少块」
——块(以及跳转要找的那些标题)要到下一帧才出现。落在这道缝里的跳转会退而停在
最后一个真正画出来的标题上,可能差几千行,并且请求随即被丢掉,没有任何人纠正它。
1 MB 的文档上,这道缝就是补画那十四秒。

大文档的第一屏不再把块切成两半

超过 1500 行的文档分两趟显示,先出顶部。那一趟可能停在 <pre> 或 $$ … $$
块的中间,未闭合的块会吞掉它后面的全部内容,直到整篇解析到达。

插件市场出错时说你的语言

「could not reach GitHub; check the network or a proxy」以前对十二种语言的读者
都是英文——红色的,而那正是最需要看懂的时刻。现在你能据以行动的两种失败
(连不上、GitHub 让你等)都翻译了,连秒数一起。

从右往左

阿拉伯语下引用块的竖线站在左边,离它标记的文字最远;源码窗格行号与代码之间的
细线也没跟着行号一起翻到另一侧。

其他

  • 解释「关于框版本号为什么会写死」的那段注释,原先挂在撤销/重做上,
    下一个改关于框的人读不到。已归位。
  • 「每个只有图标的按钮都要带提示」这条检查认不得 Material 3 的三个命名构造,
    一个没有 tooltip 的 IconButton.filled 会悄无声息地发出去。
  • 通过自动化接口切换视图模式时,答复说「已经切好了」而其实还没有——
    代理紧接着读状态可能读到旧值。
  • 启动每一步的耗时现在可以通过自动化接口读到。日志里原本只有一个数
    ——「+901 ms before Dart」——而加载可执行文件、启动引擎、读取快照
    是三个不同的问题,答案也不同。
  • 通过自动化接口存盘、同时给标签页指定文件时,答复说的是存之前那个名字,
    不是刚写出去的那个文件名——而这正是两者唯一会不一样的情况,
    也正是调用方最需要答案的那一格。
  • 自动化接口用两种语言作答:22 条拒绝理由是中文,而它说的其余一切都是英文;
    其中 5 条只写着「同上」——可它们是一条一条单独送出去的,等于什么也没说。
  • 让它关一个窗格却没说关哪个时,它回答 unknown slot "null",
    把调用方从没发过的值引述回去。「没给」和「给错」是两种答复,
    现在两种都会列出有哪些槽位。
  • 自动化工具自己的描述讲了 9 件它能做的事,而它有 13 个动作——
    少掉的是存盘、把关闭收回、打开面板和改设置。那一段是决定「要不要用这个工具」
    时最先读到的,所以它现在直接从动作本身读出清单,不再是第三份手抄件。
  • 它 17 个参数里有 3 个什么也没说,而其中一个恰恰是最需要说的:
    窗格是按象限命名的,不是按边——bottom 是左下那一格,
    协议里原本没有一处讲过。
  • 通过接口切换视图模式,还留着一小时前刚在窗格那边修掉的同一个毛病:
    没给值时回答 unknown mode "null",给错值时也不说有哪些模式。
    三处「取值来自固定集合」的地方现在答法一致,而那个集合是从取值本身读出来的。

左侧文件栏重新记得你的文件了

打开一个文档、关掉窗口、再打开另一个,左侧文件栏就把前一个忘了。它不是没恢复
——是在被读到之前就被覆盖了。带着文档启动时,程序先把那个文档打开,
而登记它的那一下就把侧栏列表存成了「只有这一个文件」,
片刻之后的恢复读到的正是它自己刚毁掉的那一份。

现在它在任何写入之前先读,读到之前拒绝写,而且是合并而不是替换
——于是这两步的顺序再也不可能弄错。

切文档、切窗格快了很多

打开第二个文件会卡,关窗口也卡。用一篇 117 KB 的文档和一篇小文档实测:
每次切换都把整篇文档从头重画,一次 190–260 ms;其中两次重画发生在同一帧
——两篇文档同时在画;有一次切换花了 3.3 秒。

两个原因,相隔一行。装着源码/预览/分屏三个窗格的那个 stack,key 里除了文档还带着
模式,于是切一次模式就把三个窗格全丢掉重建——而那个 stack 存在的理由恰恰是
避免这件事。它外面还套着 150 ms 的交叉淡入淡出,这就是「两篇文档同时在画」的来处,
而且正发生在你等着切换结束的那一刻。

「关窗口卡」是同一个毛病的另一面:关闭本身只要 20–35 ms,
但那一下点击要送到一个正忙着重建文档的线程上。

「编辑 → 撤销」不再把刚打的字弄丢

Ctrl+Z 和菜单里的「撤销」走的不是同一段代码。按键让撤销自己去读输入框;
菜单则把标签页那一份递给它——而那一份是在 300ms 防抖里才写回去的,
所以你正在打字的时候它落后于屏幕,一篇大文档正在补画时落后得更久。

撤销会把「调用方说的现在」先压进重做栈再往前退。递给它一份滞后的文本,
刚打的那几个字就从屏幕上消失、而且不在重做栈上——再也拿不回来。
打几个字然后直接去点菜单,它们就没了。

预览模式仍然用标签页那一份,因为那里没有输入框。只是有输入框的时候不再用它。

自动化接口可以在文档上动手了

format 能跑编辑器自己的任意格式命令——和格式菜单、键盘走的是同一条路。
undo / redo 退的是「编辑」菜单退的那一段历史。set_clipboard 往剪贴板放文本,
并且能像浏览器那样在旁边放一份 HTML——那正是这个编辑器粘贴时先读的那一份。

拒绝比执行更要紧。格式命令只是一个请求,由某个窗格在下一帧接手,
所以它会等到真被接手才回答,并说出文档字数的变化。纯预览且没有块在编辑时
没有任何窗格会接,于是直接拒绝并告诉你该先做什么——而那个请求会被丢掉,
不会留在那里等读者下次切到源码模式的瞬间自己触发:那会是一次没人要求、
时间也没人选的编辑。

set_clipboard 会换掉读者剪贴板里原有的东西。它在答复里说明这一点。

窗口可以从外面驱动了

set_window 能最大化、最小化、全屏、回到常态,也能指定尺寸。答复报的是窗口
变成了什么,而不是你要求了什么
——窗口管理器会把尺寸夹到工作区和窗口自身的下限,
这是两个数。它也不会把窗口缩到标题栏抓不住的程度。

这一条从一开始就在要求里,一直没做;而它正是「机器」和「剩下那些检查」之间的那道坎
——其中两条是「把窗口从 1200 拖到 700 再拖到 400,看有没有条纹」。
截图一直是能做的,动窗口不能。

关掉的标签页可以拿回来

Ctrl+Alt+R,或者「文件 → 重新打开关闭的标签页」,把刚关掉的文档开回来——
回到它原来的位置,不是追加在最后。有标签页的编辑器都有这个动作,这个没有:
要么回侧栏里把文件找出来,要么指望它还在「最近文件」里,要么在打开对话框里
把路径敲一遍。

不是 Ctrl+Shift+T——浏览器和 VS Code 用的是那个键,但在这里它是任务列表,
从上游起就是。这个动作在命令面板里,也在快捷键设置里,可以随意改绑。

记的是路径,不是正文:留住最近十个已关文档的文本,要花的内存超过这个编辑器
愿意付的价钱,所以拿回来的是磁盘上此刻的那一份。没存过盘的标签页没有路径,
不会进这个清单;而关掉一个改过的标签页本来就会先问,所以「不保存」是一个决定,
不是手滑。

自动化接口也加了 reopen_tab,理由是同一个:关闭是它唯一一个会毁掉东西的动作,
而它收不回来。

编辑器说不出自己是哪个编辑器

通过自动化接口问它,每一个发出去的构建都自称 dev。它报的版本读的是一个叫
APP_VERSION 的编译期设置,而这个名字在整个仓库里只出现一次——就是读它的那一行。
从来没有人定义过它,所以那个兜底值是它唯一给过的答案。

get_state 现在也带上版本号。编辑器把自己换成新构建、再回来之后,
「回来的是哪个」才是要紧的那件事;而握手只在连接时读一次,之后不再露面。

发行版构建能说出自己是哪个构建

启动追踪会打印一行,写明它是从哪个提交构建的。构建「没人会装的那些二进制」的
workflow 传了这个信息,构建「Releases 页面上那些」的 workflow 三个平台一个都没传
——于是读者下载到的包,对着一个 CI 构建说「这不是 CI 构建」。
这个功能之所以存在,是因为曾经有一份「启动很慢」的报告,被对着比它新好几个提交的
源码分析过——而那正是它哑掉的那一类报告。

关窗口,现在是真的把窗口关掉

读者第三次说关闭很慢,而编辑器能做的每一项测量都说它很快:从被告知关闭到窗口消失,
每一次记录都是 17 到 35 毫秒,关闭看门狗一行都没写过。

问题在于被测量的是另一段,而该测的那段没人测。于是 runner 自己量了三个时刻:
点击到达、窗口离开屏幕、进程执行最后一条指令。读者机器上的真实数据是:点击 0 毫秒
被收到,最后一条指令在 128 毫秒后——而窗口从来没有离开过屏幕。这不是测量失败,
这就是答案:

void WindowManager::Destroy() { PostQuitMessage(0); }

关闭并不销毁这个窗口。它只是请消息循环停下来,而窗口就一直站在读者面前,直到进程
自己死掉——中间是 Windows 卸载一个五十兆安装包的全过程,逐个执行它加载过的每个库的
卸载钩子。与此同时,编辑器自己的追踪写着「窗口已销毁」,因为那一行是在调用返回之后
记下的。

现在窗口立刻从屏幕上撤掉,进程也立刻结束,而不是慢慢收摊。后半句不是修辞。读者问过
一个问题:关掉编辑器之后马上打开一个文档会怎样?答案是——什么也不会发生,而且一声不响。
在那几秒里,正在死去的进程仍然握着单实例锁和那条管道(第二次启动正是把路径交给它的),
却已经没有活着的东西在读了;于是文档被交给一个死掉的接收者,那次启动随即退出。
而让窗口瞬间消失,恰恰就是在邀请读者去这样做。

窗口回来的地方,你找不到

在最小化状态下关闭编辑器,会把「窗口在哪」记下来。而最小化的窗口不在任何地方:
Windows 报的是它停放窗口的那个角落,远在所有屏幕之外,尺寸只有几十像素——这被当作
窗口的位置写了下来。下次启动就开在那里。

执行那次关闭的正是一次更新,而当时窗口是最小化的。现在,一个不在任何地方的窗口,
它的几何不会覆盖已有记录——已存的那个,是窗口最后一次确实在某处时的位置,
而这正是这份记录存在的意义。启动追踪同时打出「读到了什么」和「决定开在哪」,
因为搞清这两者是哪一个出了错,曾经要通过读者往返一趟。

打开第二个文档,不会再启动第二个编辑器

编辑器开着的时候双击一个文档,要等一秒多才有反应,而这一秒里没有一点是花在文档上的。
「我是不是已经在运行了」这个判断住在 Dart 里,而 Dart 要等引擎起来才会运行:读者机器上
实测,Windows 映射程序和它的库要 462 毫秒,引擎与快照还要六百多毫秒。一个完整的第二份
编辑器被启动起来,只为了转交一个路径然后退出。

现在 runner 在它执行的第一条指令里就问这个问题。这条路上任何一种失败都会退回到正常启动,
也就是它存在之前的样子。

编辑器会说出「出错了」和「这一帧卡了」

这里从来只报告有人特意写代码去找的失败。解析器给自己计时、预览给自己计时、启动给每个
阶段计时——而 widget 构建时抛出的异常,在发行版里就是一个灰方块、不留一个字;
没人 await 的 future 抛出的异常,打到一个窗口程序根本没有的控制台。两者在读者能打开的
日志里都是完全沉默的,而那正是诊断「慢」或「坏」要读的日志。

现在它们进日志了。说出来容易,不把日志淹掉才是真正的工作——构建抛异常的那一帧,
之后每一帧都会再抛。同一个故障只说一次,然后计数;而「同一个」刻意按故障的种类
算,不按消息算——带着下标或路径的消息每帧都不一样,故障却是同一个。

卡顿是另一件从没被测量过的事,原因一样:它按定义就是没人计时的那一段。现在编辑器会
注意到肉眼可见地慢的帧并说出它有多慢,一串卡顿只说一次。

卸载会把文件夹一起带走

程序运行时会在自己的可执行文件旁边写诊断文件。安装器没有放过它们,所以卸载器也不认识
它们,而一个陌生文件就足以让整个安装目录留在原处。删掉一个编辑器却发现它的文件夹还在,
有理由让人怀疑它还留下了些别的什么。