|
1 | 1 | # AutoPathComment |
2 | 2 |
|
3 | | -**AutoPathComment** is a Visual Studio Code extension that automatically inserts a comment at the top of your file with its **relative path** when you save. This can be useful for quickly identifying a file’s location, especially in large or multi-root workspaces. |
| 3 | +**AutoPathComment** is a Visual Studio Code extension that automatically inserts a comment at the top of your file with its **workspace-relative path** whenever you save. The path always lands immediately after any required shebangs or language directives so scripts keep working, while still giving you a quick breadcrumb to the file’s location. |
4 | 4 |
|
5 | 5 | ## Features |
6 | 6 |
|
7 | 7 | - **Auto-insertion of file path on Save** |
8 | | - Whenever you save a file in your workspace, AutoPathComment detects its relative path from the workspace root and inserts that path as a comment at the top of the file. |
| 8 | + Whenever you save, AutoPathComment detects the file’s workspace-relative path and inserts it as a top-of-file comment. |
9 | 9 |
|
10 | 10 | - **Supports Popular Languages** |
11 | | - The extension recognizes file extensions like .js, .ts, .py, .php, .java, .go, and more. It uses the appropriate comment syntax for each language (e.g., // for JavaScript, # for Python). |
| 11 | + Ships with defaults for common extensions (.js, .ts, .py, .php, .java, .go, .rb, etc.) and uses the correct single-line comment token for each. You can extend or override this map in settings. |
12 | 12 |
|
13 | | -- **Shebang Detection** |
14 | | - If a file has a shebang (e.g., #!/usr/bin/env python), the extension can optionally skip or insert the path comment *after* the shebang to avoid interfering with scripts. |
| 13 | +- **Directive-aware insertion** |
| 14 | + Shebangs, Ruby magic comments (`# frozen_string_literal`, `# encoding`), Python `coding` declarations, and PHP opening tags are detected automatically. The comment is inserted right after that preamble so executables keep their required header. |
15 | 15 |
|
16 | 16 | - **No Duplicate Comments** |
17 | | - The extension checks if the relative path comment is already present, so it doesn’t insert it again on subsequent saves. |
| 17 | + The extension checks the insertion location before writing anything, so repeated saves keep the file tidy. |
18 | 18 |
|
19 | 19 | ## Requirements |
20 | 20 |
|
21 | | -- Visual Studio Code 1.104.0 or higher |
| 21 | +- Visual Studio Code 1.105.0 or higher |
22 | 22 | - Node.js (for extension development, if building from source) |
23 | 23 |
|
24 | 24 | ## Installation |
25 | 25 |
|
26 | | -1. **From the VS Code Marketplace** (recommended): |
27 | | - - Search for "AutoPathComment" by publisher "icoretech" and install. |
28 | | - |
29 | | -2. **From a VSIX file**: |
30 | | - 1. Download the `autopathcomment-<version>.vsix` file (created by `vsce package`). |
| 26 | +1. **From a VSIX file** (current distribution): |
| 27 | + 1. Download the latest `autopathcomment-<version>.vsix` from the Releases tab or build one locally with `npm run package`. |
31 | 28 | 2. In VS Code, press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (macOS) and select **Extensions: Install from VSIX...**. |
32 | 29 | 3. Select the downloaded `.vsix` file to install. |
33 | 30 |
|
34 | | -3. **From Source**: |
| 31 | +2. **From Source**: |
35 | 32 | 1. Clone the repository or download it. |
36 | 33 | 2. Run `npm install`. |
37 | 34 | 3. Run `npm run package` or `vsce package` to create a `.vsix`. |
@@ -82,15 +79,24 @@ Examples: |
82 | 79 |
|
83 | 80 | ## Known Issues / Limitations |
84 | 81 |
|
85 | | -- **Multi-root Workspaces**: If you use multiple workspace roots, the file path is determined relative to the first matching workspace folder. If you have nested or overlapping folders, the extension may not behave as expected. |
86 | | -- **Large Files**: The extension does not differentiate between text and binary files. If you open and save very large files, insertion still occurs (though typically with minimal overhead). |
87 | | -- **Shebang**: Currently, if a shebang (`#!...`) is detected, the extension *skips* inserting the comment. This is to avoid breaking executable scripts. |
| 82 | +- **Multi-root Workspaces**: The file path is determined relative to the first workspace folder whose filesystem path prefixes the document. Nested or overlapping folders may require custom settings. |
| 83 | +- **Binary / Generated Files**: The extension does not discriminate between text and non-text files. Exclude generated artifacts via VS Code settings if needed. |
| 84 | +- **Comment Syntax**: Only single-line comment prefixes are supported. Add a custom mapping in settings if your language uses a different single-line token. |
| 85 | + |
| 86 | +## Development |
| 87 | + |
| 88 | +- Install dependencies: `npm install` (also configures the local `commit-msg` hook for Conventional Commits). |
| 89 | +- Build once: `npm run compile` |
| 90 | +- Continuous build: `npm run watch` |
| 91 | +- Run tests (VS Code integration via `@vscode/test-cli`): `npm test` |
| 92 | +- Full check (types + lint + tests): `npm run check` |
88 | 93 |
|
89 | 94 | ## Contributing |
90 | 95 |
|
91 | 96 | 1. Fork and clone the repo. |
92 | | -2. Create a new branch for your feature or bugfix. |
93 | | -3. Open a pull request describing your changes. |
| 97 | +2. Run `npm install` (sets up commit hooks locally). |
| 98 | +3. Create a new branch for your feature or bugfix. |
| 99 | +4. Open a pull request describing your changes. |
94 | 100 |
|
95 | 101 | ## License |
96 | 102 |
|
|
0 commit comments