Editor/HotCodeEditor/EditorDocument.cs

Editor-side document model for the HotCode editor. Tracks a file path, its CodeView instance, dirty/preview state, BOM, last edit time, live-check markers and ad-hoc diagnostics.

/// <summary>
/// A file open in a tab. Each document keeps its own CodeView so undo history and
/// scroll position survive switching tabs.
/// </summary>
public class EditorDocument
{
	/// <summary>
	/// Where the file lives. Changes when it's renamed or moved from the file tree.
	/// </summary>
	public string Path { get; set; }
	public CodeView Editor { get; }

	/// <summary>
	/// Has edits that aren't written to disk yet.
	/// </summary>
	public bool IsDirty { get; set; }

	/// <summary>
	/// Opened with a single click; gets replaced by the next single-clicked file
	/// unless it's edited or double-clicked.
	/// </summary>
	public bool IsPreview { get; set; }

	/// <summary>
	/// The file started with a UTF-8 byte order mark, so keep writing one.
	/// </summary>
	public bool HasBom { get; init; }

	/// <summary>
	/// RealTime.Now of the last edit, for auto save.
	/// </summary>
	public double LastEdit { get; set; }

	/// <summary>
	/// Edited since the last check-while-typing pass.
	/// </summary>
	public bool NeedsLiveCheck { get; set; }

	/// <summary>
	/// Underlines from checking while typing; null means use s&amp;box's last compile instead.
	/// </summary>
	public System.Collections.Generic.IReadOnlyList<EditorMarker> LiveMarkers { get; set; }

	/// <summary>
	/// Problems HotCode reports for this file that s&amp;box doesn't (see DiagnosticsProvider). Reset after each compile.
	/// </summary>
	public System.Collections.Generic.HashSet<string> Noise { get; set; }

	public string Title => System.IO.Path.GetFileName( Path );

	public EditorDocument( string path, CodeView editor )
	{
		Path = path;
		Editor = editor;
	}
}