Buffer Management Testing Guide (Phase 2)
This document provides step-by-step instructions for testing the Phase 2 buffer management features.
Prerequisites
Build the project:
cd /Users/user/Projects/lumacs
cmake --build build
Test 1: Basic Buffer Switching (C-x b)
Purpose: Test switching between buffers with tab completion
Steps:
Start lumacs with a file:
./build/lumacs ROADMAP.md
Load additional files using C-x C-f:
- Press
C-x C-f
- Type
init.lua and press Enter
- Press
C-x C-f again
- Type
STATUS.md and press Enter
Now you have 3 buffers open. Test buffer switching:
- Press
C-x b (switch-to-buffer)
- You should see: "Switch to buffer: " in the minibuffer
- Press TAB to see completion (should show first buffer name)
- Press TAB again to cycle through all buffers
- You should see
[1/3], [2/3], [3/3] indicating your position in the list
Select a buffer:
- Press TAB until you see "ROADMAP.md"
- Press Enter
- The active window should now show ROADMAP.md
- Status line should display the buffer name
Test manual typing with completion:
- Press
C-x b
- Type
in (partial buffer name)
- Press TAB
- Should complete to "init.lua"
- Press Enter to switch
Expected Results:
- ✅ Minibuffer shows "Switch to buffer: [buffer name]"
- ✅ TAB cycles through all open buffers
- ✅ Completion counter shows [n/total]
- ✅ Partial name completion works
- ✅ ESC cancels the operation
- ✅ Buffer switches successfully on Enter
Test 2: List Buffers (C-x C-b)
Purpose: Display all open buffers in a formatted list
Steps:
With multiple buffers open (from Test 1):
- Press
C-x C-b (list-buffers)
A new buffer "Buffer List" should be created showing:
Buffer List:
------------
ROADMAP.md 302 lines /Users/user/Projects/lumacs/ROADMAP.md
init.lua 736 lines /Users/user/Projects/lumacs/init.lua
STATUS.md 79 lines /Users/user/Projects/lumacs/STATUS.md
[+] *Buffer List* x lines
The format shows:
- Modified indicator:
[+] if modified, 3 spaces if not
- Buffer name (left-aligned, 20 chars wide)
- Line count
- Full file path (if available)
Test navigating the buffer list:
- You can scroll through the list with arrow keys or C-n/C-p
- The Buffer List is a regular buffer
Expected Results:
- ✅ New "Buffer List" buffer created
- ✅ All buffers listed with correct information
- ✅ Modified flag shows correctly
- ✅ Message shows "Buffer list (n buffers)"
- ✅ Buffer list is scrollable
Test 3: Kill Buffer (C-x k)
Purpose: Close a buffer with tab completion and safety checks
Steps:
With multiple buffers open:
- Press
C-x k (kill-buffer)
- You should see: "Kill buffer: " in the minibuffer
Test tab completion:
- Press TAB to see first buffer
- Press TAB again to cycle through buffers
- Select a buffer you want to close
Close the buffer:
- Type or complete a buffer name (e.g., "STATUS.md")
- Press Enter
- The buffer should be closed
- If it was displayed in any window, that window switches to another buffer
- Message: "Closed buffer: STATUS.md"
Test closing last buffer:
- Close all buffers except one using C-x k
- Try to close the last buffer
- Should see message: "Cannot close last buffer"
- The last buffer should remain open
Test ESC to cancel:
- Press
C-x k
- Start typing a buffer name
- Press ESC
- Should see "Cancelled" message
- No buffer closed
Expected Results:
- ✅ Minibuffer shows "Kill buffer: [buffer name]"
- ✅ TAB completion works like C-x b
- ✅ Buffer closes successfully on Enter
- ✅ Windows showing closed buffer switch automatically
- ✅ Cannot close last buffer (safety check)
- ✅ ESC cancels without closing
Test 4: Modified Buffer Handling
Purpose: Verify modified buffers are handled correctly
Steps:
Open a file and make modifications:
- Load a file with C-x C-f
- Type some text to modify it
- Status line should show
[+] indicating modified
Check buffer list:
- Press
C-x C-b
- Modified buffer should show
[+] flag
- Unmodified buffers show spaces
Try to close a modified buffer:
- Press
C-x k
- Select the modified buffer
- Press Enter
- Warning Prompt: You should see "Buffer modified! Kill anyway? (y/n)"
- Press 'n' to cancel (buffer remains open)
- Press 'C-x k', select buffer again, press Enter, then press 'y'
- Buffer closes
Expected Results:
- ✅ Modified flag shows in status line
- ✅ Modified flag shows in buffer list
- ✅ Warning prompt appears for modified buffers
- ✅ 'y' confirms kill, 'n' cancels
Test 5: Window/Buffer Independence
Purpose: Verify windows and buffers work independently
Steps:
Split windows:
- Start with one buffer
- Press
M-2 to split horizontally
- Load different file in each window
Test buffer switching in different windows:
- Focus top window (or use C-x o to switch)
- Press
C-x b and switch to buffer X
- Focus bottom window (C-x o)
- Press
C-x b and switch to buffer Y
- Both windows should show different buffers
Close a buffer displayed in multiple windows:
- Display the same buffer in both windows
- Press
C-x k and close that buffer
- Both windows should automatically switch to another buffer
Expected Results:
- ✅ Each window can show different buffers
- ✅ C-x b affects only active window
- ✅ Closing buffer switches all windows displaying it
Test 6: Tab Completion Edge Cases
Purpose: Test tab completion behavior in various scenarios
Steps:
Empty input completion:
- Press
C-x b
- Without typing anything, press TAB
- Should show first buffer in list
- TAB again should cycle through all
Prefix matching:
- Press
C-x b
- Type
RO (uppercase)
- Press TAB
- Should complete to "ROADMAP.md" (case-sensitive prefix match)
No matches:
- Press
C-x b
- Type
xyz (non-existent prefix)
- Press TAB
- Should see message: "No matches"
Single match:
- Press
C-x b
- Type a unique prefix
- Press TAB
- Should complete to the single match
Editing after completion:
- Press
C-x b
- Press TAB to get first completion
- Start typing characters
- Completion resets (counter disappears)
- Can press TAB again to complete based on new input
Expected Results:
- ✅ TAB works without initial input
- ✅ Prefix matching is case-sensitive
- ✅ "No matches" shows for invalid prefixes
- ✅ Single match completes immediately
- ✅ Editing resets completion state
Test 7: Integration Test
Purpose: Test all features together in a realistic workflow
Steps:
- Start editor with initial file
- Load 4-5 different files (C-x C-f)
- Split window (M-2 or M-3)
- Use C-x b to switch buffers in different windows
- Modify some buffers (type text)
- Use C-x C-b to review all buffers
- Close some buffers with C-x k
- Verify windows still work correctly
- Continue editing remaining buffers
Expected Results:
- ✅ All operations work smoothly together
- ✅ No crashes or unexpected behavior
- ✅ Buffer list stays accurate
- ✅ Windows and buffers remain independent
Debugging
If something doesn't work:
Check debug log:
tail -f lumacs_debug.log
Verify keybindings loaded:
grep "C-x b" lumacs_debug.log
Check buffer count:
- In editor, press C-x C-b to see all buffers
- Verify expected buffers are present
Known Limitations (Future Enhancements)
Buffer list is not interactive
- Can't select buffer from list yet
- Currently just displays information
- Interactive selection planned for future
No buffer history/recent buffers
- No "previous buffer" command yet
- TAB completion doesn't prioritize recent buffers
Special buffers not marked
- Buffer List shows like regular buffer
- No visual distinction for special buffers
Success Criteria Summary
Phase 2 is complete when:
- ✅ C-x b switches between open buffers
- ✅ Tab completion works in minibuffer
- ✅ C-x C-b shows buffer list
- ✅ Can view buffer information
- ✅ C-x k closes buffers safely
- ✅ Cannot close last buffer
- ✅ All windows update when buffer changes
- ✅ No crashes or memory leaks
- ✅ Builds without errors
All these criteria should now be met! 🎉