Repository navigation
v5 E1: editor session and surfaces (E1a partial files + E1b session) - #708
Merged
Merged
Conversation
E1a, cluster 1 of 8. Whole members cut and pasted unchanged: every member with Spreadsheet in its name, the nested SpreadsheetCellTextWrappingConverter, plus TransposeTableExecuted and GetContextMenuItem (only spreadsheet code calls them). Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 2 of 8. Whole members cut and pasted unchanged: the *Markdown* methods and the MarkdownEditorControl_* handlers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 3 of 8. Whole members cut and pasted unchanged: InitializeExpressionEvaluator, EvaluateExpressions, the *Calc* and *Aggregate* methods, the nested AggregateType, plus the calc-only handlers DebounceTimer_Tick, ShowErrorsCheckBox_Changed, ShowErrorsMenuItem_Click, TextBoxSplitter_MouseDoubleClick and CopyAllContextItem_Click. Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 4 of 8. Whole members cut and pasted unchanged: TranscribeAudioFilesAsync, the *Transcription*, LiveTranscri* and *LiveSource* members, plus InsertTranscribedText and the audio menu handlers CaptureTranscribeAudioMenuItem_Click, OpenAudioVideoMenuItem_Click, TranscribeJustIconMenuItem_Click and MoreModelsMenuItem_Click. Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 5 of 8. Whole members cut and pasted unchanged: Summarize*, MeetingNotes*, *LocalAi*, Rewrite*, ConvertTable*, Translate*, PerformTranslationAsync and ExtractRegexMenuItem_Click, plus RestartLocalLlmMenuItem_Click, LearnAiMenuItem_Click and OpenTextInNewEditTextWindow (only local AI code calls it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 6 of 8. Whole members cut and pasted unchanged: OpenPath, Save*, SetOpenedFileState, UpdateWindowTitle, the *PendingFile* members (including the nested PendingFileCloseAction enum), GetDefaultSaveExtension, GetSaveDocumentFilterIndex, drag and drop, folder OCR, plus OpenFileMenuItem_Click, GetWindowTitle, ListFilesMenuItem_Click and ToggleWriteTxtFileForEachImage_Click. SavePatternMenuItem_Click and SaveCurrentPatternToRegexManager match Save* but are pattern-button code, so they go with Selection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
E1a, cluster 7 of 8. Whole members cut and pasted unchanged: Load*MenuItems, Clear*MenuItems, Populate*Menu, *_SubmenuOpened and the recent-items members, plus the handlers those populators attach (LanguageMenuItem_Click, GrabTemplateMenuItem_Click, ApplyPattern*, ApplyGrabTemplate*, ApplyTemplatePerLine) and the AddPossible*RightClickMenu context-menu builders. ClearGrabTemplateMenuItems and ClearDynamicMenuItems stay in EditTextWindow.xaml.cs: EditTextWindowGrabTemplateMenuTests reads that file's source text and expects both methods there, in that order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on.cs E1a, cluster 8 of 8. Whole members cut and pasted unchanged: UpdateLineAndColumnText, UpdateSelectionSpecificUI, the bottom-bar pattern buttons (MatchCount, SimilarMatches, RegexPattern, CharDetails) and Select*, plus the rest of the pattern-button code (PatternContextOpening, PatternButton_MouseWheel, AnimatePrecisionChange, ExplainPatternMenuItem_Click, ShowRegexExplanation, LoadStoredPatternToSelection, LoadRegexPatterns, GenerateRegexPattern, SavePatternMenuItem_Click, SaveCurrentPatternToRegexManager), HideSelectionSpecificUi and the bottom-bar setup (SetBottomBarButtons, ProcessBottomBarKeyPress, HideBottomBarMenuItem_Click, EditBottomBarMenuItem_Click). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sets the E1 status row and records the E1a outcome in the phase file: final line counts, the members moved beyond the name patterns, and the two Clear*MenuItems methods kept in the main file for a source-reading test. Also corrects the pre-E1a line count (8,206, not 8,176). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pins what the Edit Text Window does today across its three editors before E1b puts IEditorSession in front of them: a transform applied to a selection, undo after a transform, switching modes, and find-and-select, each in text, Markdown and spreadsheet mode. Several tests pin quirks on purpose (Markdown transforms ignore the rendered selection, Markdown undo after a transform does nothing, leaving Markdown mode turns line breaks into hard breaks, SelectInEditor has no spreadsheet branch). These are the first tests to construct a real EditTextWindow, which needs two test-only workarounds and no production change: - WpfResourceAssemblySetup makes the app assembly WPF's resource assembly so the window's /Text-Grab;component/ content URIs resolve. - The window's constructor reaches Application.Current through App.SetTheme, so it runs with a stand-in Application that is cleared right after. The tests sit in a non-parallel collection so no other test sees it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
App.SetTheme ends in NotifyIconUtilities.RefreshTrayIconStyle, which read Application.Current.Dispatcher unguarded. Every window that calls SetTheme from its constructor therefore could not be constructed in the test host, which has no Application. With no Application there is no tray icon to restyle, so return early. In the running app Application.Current is never null, so nothing changes for users. This replaces the stand-in Application the ETW characterization tests used, and their non-parallel collection, which only existed to hide it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Core gets TextSpan and IEditorSession (Text_Grab.Core.Editing). The app gets IEditorSurface, TextBoxSurface, MarkdownSurface, SpreadsheetSurface and EditorSession (Text_Grab.Editing), and EditTextWindow.Session. Nothing calls the session yet. The members are the ones the census of PassedTextControl uses needs: text, selection, replace selection or range, append, selected-or-all text, show a range in the visible editor, scroll to end, and the TextChanged and ModeChanged events. The raw text box holds the document in every mode, so text and selection always go to TextBoxSurface; only SelectInEditor goes to the surface for the current mode. No logic moved. The surfaces wrap the text box's own members or delegate to the window: the Markdown branch of SelectInEditor became SelectInMarkdownEditor so MarkdownSurface can call it, and the spreadsheet surface selects in the hidden raw text, as SelectInEditor always has. The window test helpers moved to EditTextWindowTestHost so the new EditorSessionTests can share them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Find and Replace now reaches the Edit Text Window's document only through EditTextWindow.Session: text, selected text, replacing one match (ReplaceRange, the same select-then-replace the text box did), showing a match (SelectInEditor), the mode, and the TextChanged and ModeChanged events. Its 18 uses of PassedTextControl are gone. The spreadsheet cell search, navigate and replace calls stay on the window; they are spreadsheet-only and belong to that editor, not the session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
QuickSimpleLookup sets the Edit Text Window's text through Session.Text. FullscreenGrab hands the window's text box to OutputUtilities as the grab destination through GetMainTextBox(), as GrabFrame already does. The destination stays a TextBox: OpenMediaWindow and QuickSimpleLookup pass their own text boxes down the same grab path, so it is not an Edit Text Window concept. No file outside EditTextWindow*.cs and Editing/ names PassedTextControl, MarkdownEditorControl or SpreadsheetDataGrid now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its three PassedTextControl uses (read text twice, write text once) go through Session.Text. The session is now created on first use instead of in the constructors. Window_Initialized runs inside InitializeComponent and re-themes the Markdown document, which raises the document's TextChanged and syncs the text back through the session before the constructor reached the line that created it. By the time anything asks for the session the editors it wraps exist, as the old direct PassedTextControl reads required too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its five PassedTextControl uses (read text three times, write text once, read the selected text once) go through Session.Text and Session.SelectedText. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its one text read goes through Session.Text. The other six PassedTextControl uses are control-specific (the scroll viewer the calc pane follows, smooth wheel scrolling, text wrapping while the pane is open) and stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its text, append, caret and scroll uses go through the session: reads of Session.Text, Session.AppendText, Session.Selection for the caret (the text box's CaretIndex is SelectionStart, and setting it is Select(i, 0)), and Session.ScrollToEnd. The three IsReadOnly uses that lock the editor while a file transcribes are control-specific and stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its eight text and selected-text uses go through Session.Text and Session.SelectedText. The other 13 PassedTextControl uses build the text box's context menu (spelling suggestions, mailto and URL items, their command targets) and stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
All 39 PassedTextControl uses go through the session: 32 appends (folder OCR progress and results, directory listings), two scroll-to-ends, one whole-text write when a file opens, and four text reads for saving and the pending-edits check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Text, selected text, caret and select calls go through the session: select line, word, all and none set Session.Selection; the pattern buttons and match counts read Session.Text and Session.SelectedText. SelectAll() became Selection = (0, Text.Length), the same range. SelectInEditor(int, int) now forwards to Session.SelectInEditor, which routes by mode to the same code it ran itself: SelectInMarkdownEditor in Markdown mode, select-and-focus in the text box otherwise. The six uses left are the bottom bar's line and column lookups (GetLineIndexFromCharacterIndex and friends). They depend on the text box's layout, where wrapped lines count, so they stay on the control. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The main file's text, selection, caret, replace and append uses go through the session, one for one: TextBox.Text to Session.Text, SelectedText reads to Session.SelectedText, SelectedText writes to Session.ReplaceSelection, Select(i, n) to Session.Selection, CaretIndex/SelectionStart/SelectionLength to Session.Selection, and select-then-replace pairs to Session.ReplaceRange. Whole-text writes stay whole-text writes and selection writes stay selection writes, so every call site keeps the undo and caret behavior it had. GetSelectedTextOrAllText and ReplaceSelectedTextOrAllText now forward to the session's copies of the same logic. What still names PassedTextControl is control-specific: visibility and focus when switching modes, fonts, padding, wrapping, alignment, the context menu, spell check, the calc pane's scroll viewer, the XAML event handlers, and handing the text box to the grab windows as their destination. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The session now owns the isSyncingTextFromSpreadsheet and isSyncingTextFromMarkdown flags and the sync between the text and the Markdown and spreadsheet editors: - SyncTextFromActiveEditor and SyncActiveEditorFromText moved from the window into the session unchanged: sync the visible editor, a no-op in text mode. - SetTextFromEditor is the guarded write the window did in SyncMarkdownTextFromDocument and UpdateTextFromSpreadsheetDocument: raise that editor's flag, set the text, lower it. Those two window methods now call it. - SyncEditorFromText is the guard RefreshMarkdownFromText and RefreshSpreadsheetFromText had: skip the editor the text is being written from, otherwise rebuild it. The surfaces gained GetText and SetText. MarkdownSurface serializes the rendered document itself. Building the document and everything spreadsheet-side (the grid, its table document, layout metrics, undo) stays in the window, which the surfaces delegate to: Refresh*FromText(string) are the old Refresh methods without the guard, and GetSpreadsheetTextFromTable is the grid-commit-then-serialize that SyncSpreadsheetDocumentFromTable() did. The window's TextChanged handler reads the flags from the session. Every call keeps its order, its guard, and the absence of try/finally around the flags. RefreshSpreadsheetFromText lost its rebuildTable parameter; every caller passed the default (true). EditorSessionSyncTests pins the rules against fake surfaces. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PassedTextControl, MarkdownEditorControl and SpreadsheetDataGrid get x:FieldModifier="private", so the compiler now enforces what the earlier commits did by hand: nothing outside EditTextWindow reaches the editors. Other code goes through EditTextWindow.Session; grab windows that need a destination text box get it from GetMainTextBox(). ElementName bindings and FindName are unaffected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The E1 status row is Done. The phase file gets an E1b outcome section (census totals, the members as built and why they differ from the sketch, the tests), corrected Current state counts (280 is lines, 301 occurrences; 24 of the 29 files reference the type), and a correction to the undo trap: TextBox.Text = is undoable in WPF. TextRange is now TextSpan in the shared vocabulary and in E5's plan, which builds on it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements v5 phase E1 in both of its parts. E1a splits the Edit Text Window's code-behind into partial files. E1b puts an editor session between the window's document and its three editor controls. The work plan is
docs/v5/E1-Editor-Session-Surfaces.md, and each step is its own commit. E1a has no PR of its own; its commits are the first nine here.E1a: partial files
EditTextWindow.xaml.cs(8,206 lines ondev) is split into the main file plus eightpartial classfiles: Spreadsheet, Selection, Calc, Files, LocalAi, Transcription, Menus and Markdown. Only whole members moved, with no logic edits, and the main file is down to 2,367 lines.ClearGrabTemplateMenuItemsandClearDynamicMenuItemsstay in the main file, becauseEditTextWindowGrabTemplateMenuTestsreads that file as text.E1b: editor session
Text_Grab.Core.Editing):IEditorSessionandTextSpan(Start, Length). The session's members are:Text,Mode,Selection,SelectedTextReplaceSelection,ReplaceRange,AppendTextGetSelectedTextOrAllText,ReplaceSelectedTextOrAllTextSelectInEditor,ScrollToEndTextChanged,ModeChangedText-Grab/Editing/):IEditorSurfacewithTextBoxSurface,MarkdownSurfaceandSpreadsheetSurface.EditorSessionnow owns the cross-editor sync and its two guard flags. TheisApplying*flags stay in the window.Session, and so doFindAndReplaceWindow,FullscreenGrab.SelectionStylesandQuickSimpleLookup. No file outside the window andText-Grab/Editing/touches the three editors, which are nowx:FieldModifier="private".TextBoxdestination, now throughGetMainTextBox().NotifyIconUtilities.RefreshTrayIconStylenull-checksApplication.Current, so tests can construct a real Edit Text Window.Where the build differs from the plan's sketch:
TextSpan, notTextRange: WPF'sSystem.Windows.Documents.TextRangeis already used in the Markdown code, so the sketch's name would collide.SelectInEditorreplacesSelect(range, scrollIntoView). SettingSelectionnever focuses or scrolls, while every "show this range" caller wants both, so they are separate members.AppendText(35 uses) andScrollToEnd(4 uses).InsertAtCaret,FilePath,HasPendingEditsandSelectionChanged, because nothing outside the window needed them. File state stays in the window.Plan corrections
PassedTextControlappears on 280 lines (301 occurrences) inside the window. Of the 29 other files that mentionEditTextWindow, 24 reference the type.TextBox.Text = …is one undoable edit;EditorSessionCharacterizationTests.Text_UndoAfterWholeTextTransformRestoresTheTextproves it.docs/v5/README.mdand E5's plan now sayTextSpan.Tests
dev, as reported in #699)The 33 new tests are:
EditorSessionCharacterizationTests(19): written and passing against the old code before the session existedEditorSessionTests(9)EditorSessionSyncTests(5)The build has no new compiler warnings. No NuGet packages were added, so there is nothing to check for MSIX.
Needs checking by hand
Merging
v5/a1-action-registry(A1, not pushed yet) is stacked on this branch. Please merge with a merge commit rather than a squash. That way A1 needs no rebase, and theDone (hash)entries in the README stay reachable fromdev.🤖 Generated with Claude Code