Based on the initial code review, here is a list of proposed fixes, feature suggestions, code restructure, and improvements to elevate the Tide editor.
-
Piece Table
Deleteperformance bottleneck- Location:
internal/buffer/piece_table.go - Issue: The
Deletefunction states it is using a "simpler (but less optimal) approach". Currently, it converts the entire buffer text to a byte sliceBytes(), slices out the deleted text, and creates a completely new piece table. This acts as a single contiguous array operations, resulting inO(N)memory allocation and copying on every deletion. - Fix: Rewrite
Deleteto slice the existingpiecesarray, splitting the targeted pieces and removing the removed range incrementally without rebuilding the text array.
- Location:
-
Synchronous highlighting block on launch
- Location:
internal/app/app.go - Issue: The initial syntax highlighting uses
HighlightBuffersynchronously on the main thread duringNewApp. For very large files, this can cause a noticeable delay or UI freeze before the main editing loop starts or the first frame is drawn. - Fix: Push the initial tree-sitter highlighting into a background goroutine and dispatch an event (e.g.,
TypeHighlightComplete) to request a redraw once it's done.
- Location:
-
Silent load failures on non-existent file errors
- Location:
internal/app/app.go - Issue: If
buf.Load(filePath)returns an error (like permission denied), it logs a warning but proceeds to open an empty buffer. If the user hits save, they might create a local file with the same name, or clobber things due to state desync. - Fix: Halt editor execution or show a prominent error UI overlay instead of proceeding with an empty buffer when a file exists but cannot be read.
- Location:
-
Global/Range Find and Replace (
:%s)- Details: Currently
:s/only works on the current line. Implement standard Vim-like global buffer replace:%s/pattern/replace/gand range replace:'<,'>s/....
- Details: Currently
-
Visual Mode Capabilities
- Details:
ModeVisualandModeVisualLineexist inmodehandler.gobut lack completeness. Implement full actions:d(delete selection),y(yank selection), and allow pastingpover an active selection.
- Details:
-
Atomic Undo/Redo Transactions
- Details: The README explicitly points out global replace/plugin operations don't play well with Undo. Implement
GetHistoryManager().BeginTransaction()andEndTransaction()to group multiple buffer edits into a single atomic history item.
- Details: The README explicitly points out global replace/plugin operations don't play well with Undo. Implement
-
Terminal Mouse Drag Selection
- Details:
ModeHandlerhandles click events but ignores drag events. Listen totcell.EventMousemotion with Button1 held to actively update theselectionManagervisually.
- Details:
-
Dirty-Line / Delta Rendering (
tcell)- Improvement: Currently, actions trigger
a.requestRedraw()which clears and draws the entire viewport from scratch. Introduce a "dirty lines" system tocore.Editor. TheTUIcan then only redraw lines that have changed or scrolled, vastly improving responsiveness over SSH or slow terminals.
- Improvement: Currently, actions trigger
-
Optimize Line Indexing in Buffer
- Improvement:
PieceTable'spositionToOffsetiterates through the lines array decodingutf8runes linearly from0topos.Line. While acceptable for small files, thisO(N)traversal degrades heavily. Implementing a cached binary search tree or interval tree for line byte offsets will make cursor jumpsO(log N).
- Improvement:
-
Strict Model-View Separation
- Improvement: Move UI-coupled event logic out of the
core. Theeditor.gofile referencesredrawingfunctions and specifictcellstyling constraints. Ensurecoreoperates strictly on data structures (Buffers, Cursors), emittingevent.Managerevents that theapportuilistens to for triggering view refreshes.
- Improvement: Move UI-coupled event logic out of the