CodeTrail
Trace selected code and file history first. Explore branches, commits, and statistics in the Graph tab.
Authors and Project Origins
This project builds on Git-Look, the open-source project created by wangx7. The original project introduced the branch graph, inline blame, selection history, file history, and commit statistics. Thank you to the original author for creating and sharing this foundation.
The current author and extension publisher is wangxdmm, who continues to maintain the project and has added exact text history search. The project retains the MIT license and the original author's copyright notice.
🚀 Features
1. 🔍 Selection History
- Track a code block: Select one or more lines and choose
CodeTrail: Show Selection History from the editor context menu.
- Search typed or pasted text: In Selection History, enter single-line or multiline text, click Choose file… to filter the current repository’s tracked files by path, then click Search. This searches the selected file’s local HEAD history and shows its first matching version, without requiring line numbers. Spaces, indentation, and case are significant. You can cancel the search or edit the text and search again. The input and chosen file survive panel restoration; switching repositories clears the file selection while keeping the text.
- Review the matching version first: The First matching version section at the top checks the current file’s history in reversed Git output order and returns the first version containing the complete selected text, regardless of line number. The full selection and its file populate the editable search input, with no character or line truncation. Select the card to open its diff at the historical file and matching text.
- Follow changes: The Selection history section below preserves the original line-based tracing, newest-first history, and uncommitted changes. Its cards still open the changes to the selected lines. A commit may appear in both sections because they answer different questions.
- Keep reviewing while searching: The two sections load independently. Cancel the origin search without losing the line history. Background results preserve your selection and scroll position and do not reopen a pane you have left.
- Current-line history: With no text selected, the command continues to show the current line's history without running a text search.
2. 🗂️ File History
- Browse file history: Choose
CodeTrail: Show File History to open the current file's commits in the File History tab. While this tab is active, it follows the current editor file, including the right-hand file of a standard two-pane diff. Switching diff sides keeps the same file history, which is queried from the current HEAD rather than the compared revision.
- File actions throughout the panel: File paths in the search form, selection and file history headers, first-match details, commit file lists and trees, and overview/author file statistics have Open File and Show File History buttons. Open File opens the displayed path in the working tree and reports if it no longer exists. Show File History opens its complete history without opening a diff; deleted files remain searchable, and files without commits show an empty history. In the file history header, the history button refreshes that file. The selection history header still locates the first matching commit when available.
- Compare versions: Open a side-by-side diff between a historical version and the local file.
3. 🔎 Find Text Origin
- Complete text search: Select text and choose
CodeTrail: Show Selection History. Supports single-line and multiline selections, including unsaved text. Matching is literal and case-sensitive, preserving indentation and spaces. Like log.sh, both the selection and historical content normalize CRLF to LF and discard trailing newlines. A selection containing only newlines has no match.
- File history order: Read
git log --follow --name-only -z for the current HEAD, reverse its output, and inspect each historical file in full. Return the first matching version; commit timestamps are displayed but do not rank results. Rename, copy, and merge traversal follows Git’s default --follow behavior. This is a matching snapshot, not a claim that the commit introduced the text.
- Parent checks: For each real parent of the result, show whether the same historical path contains the selected text, does not contain it, or does not exist. Parent checks are informational and never exclude a matching version. Root commits are labeled as having no parents.
- Inspect the result: Click a history card’s SHA badge to copy its full SHA without opening the diff. The result shows its author, committer time, historical path, and matching line. Click the card or file link to compare that path against the first parent and select the matching text. A missing parent path opens as an empty file.
- Local and cancellable: Cancel a search at any time. Searches do not fetch remote history. Shallow clones label results as “First match in available local file history.”
4. 📂 CodeTrail Git Graph
- Commit search in context: In Graph, type a commit message or hash into Search message or hash, then click the branch icon in the action row below the search box (shown only while search text is entered) (Show search results in the full graph). Matching commits get a ring and a Match badge in the full local branch graph. Use the up/down buttons to visit matches in search-result order; the list icon (Show only matching commits) restores the filtered view and its position. A
+ after the result count means more matching commits can be loaded. Context loading supports cancellation and retry, including commits older than the first 3000 entries.
- Branch history: Graph uses the swimlane layout and SVG geometry ported from VS Code 1.148.0 Source Control Graph, with native theme colors, compact 22px rows, HEAD markers, and grouped branch/tag badges. Virtual scrolling, filtering, pagination, and search-in-context remain available.
- Combined filters: Filter by branch, author, date range, commit hash, or commit message keywords.
- Commit details: Select a commit to inspect its metadata and changed files, then open a diff to review the changes.
- Statistics: View contributor rankings, daily commit activity, and frequently modified files.
- Main views: Switch between Selection History, File History, and Graph. All three views share a resizable bottom commit details area. Hover over the time button on the right to update details after a 50 ms debounce; moving away cancels the pending preview. Clicking the commit row updates details immediately. Hovering or focusing the row body leaves the current details unchanged. The time button also supports keyboard focus and clicks without selecting the row or opening a diff; the last preview remains when the pointer leaves. Icon tabs show complete commit information (the default), changed files with tree/list and diff actions, and the statistics overview with commit totals, additions/deletions, activity, contributors, and top files. The statistics tab keeps its chart filtering interactions; author details keep their existing layout controls. Each tab keeps its content and scroll position, with relevant actions in a fixed row below the tabs. Use Left/Right arrows or Home/End while a tab has focus. Background results do not switch tabs, and clicking the same commit again keeps its details open.
5. ✍️ Inline Blame
- Inline annotations: See the last author and commit time beside the current line as you move the cursor.
- Linked views: Connect line annotations with the status bar and graph highlights or commit details.
- Quick toggle: Enable or disable inline annotations from the editor context menu.
- At a glance: See the last author, commit time, and contributor count at the top of a file.
- Quick access: Select the author to open the latest file diff, or select the contributor count to toggle line annotations.
- Local changes: Unsaved or uncommitted changes identify the current user as “You.”
🛠️ Getting Started
1. Open History
Open CodeTrail in the bottom panel, alongside Terminal and Output. Selection History is the default view: select code and run CodeTrail: Show Selection History to trace it. Use File History to follow the current file, or Graph for branch history, filters, and commit details. Reopening the panel restores your last selected tab.
The repository selector is shared by all three tabs. Graph filters apply only to Graph; its branch menu always lists the checked-out branch first with a (current) label. Selecting a branch filters the graph without checking out that branch.
Open a tracked file to see Git information at the top. Select the author/date to view the latest diff, or select the contributor count to toggle line annotations. To hide the header, choose CodeTrail -> Git File Header from the context menu.
Right-click in the editor for the history commands and the CodeTrail submenu:
Editor Context Menu
├── CodeTrail: Show Selection History (or Show Line History without a selection)
├── CodeTrail: Show File History
└── CodeTrail
├── Toggle Inline Blame
└── Toggle File Header
- Responsive loading: Debounced file watchers and Git result caching reduce repeated queries and improve loading in large repositories.
- Theme support: Adapts to VS Code's light and dark themes with consistent typography and smooth transitions.
- History inspection: The extension does not commit or push your changes. Its fetch action retrieves remote updates without changing local branches or working files.
| |