Skip to content

Commit 3a97acf

Browse files
committed
initial commit
1 parent bd733f3 commit 3a97acf

File tree

15 files changed

+1590
-0
lines changed

15 files changed

+1590
-0
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out
2+
dist
3+
.vscode
4+
*.gif
5+
assets/

.eslintrc.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"es2022": true,
5+
"node": true
6+
},
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"project": "./tsconfig.json",
10+
"sourceType": "module"
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"extends": [
14+
"eslint:recommended",
15+
"plugin:@typescript-eslint/recommended",
16+
"prettier"
17+
],
18+
"rules": {
19+
/* ── style you care about ── */
20+
"quotes": ["error", "single", { "avoidEscape": true }],
21+
"semi": ["error", "always"],
22+
/* ── pragmatic relaxations ── */
23+
"no-console": "off", /* allow console.* while iterating */
24+
"@typescript-eslint/no-explicit-any": "off",
25+
"@typescript-eslint/no-unsafe-member-access": "off",
26+
"@typescript-eslint/no-unsafe-call": "off",
27+
"@typescript-eslint/no-unsafe-argument": "off",
28+
"@typescript-eslint/no-unsafe-assignment": "off",
29+
"@typescript-eslint/restrict-template-expressions": "off",
30+
"@typescript-eslint/no-floating-promises": [
31+
"warn",
32+
{ "ignoreIIFE": true }
33+
],
34+
"prefer-const": "warn"
35+
},
36+
"ignorePatterns": [
37+
"out/**",
38+
"dist/**",
39+
"assets/**",
40+
"*.gif",
41+
"*.png"
42+
]
43+
}

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# .github/workflows/ci.yml
2+
name: CI
3+
on: [push, pull_request]
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-node@v4
10+
with: { node-version: 20 }
11+
- run: npm ci
12+
- run: npm run lint
13+
- run: npm run compile # already in your package.json

.gitignore

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Compiled output
2+
out/
3+
*.vsix
4+
5+
# Node modules
6+
node_modules/
7+
8+
# Logs
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
13+
# OS generated files
14+
.DS_Store
15+
.DS_Store?
16+
._*
17+
.Spotlight-V100
18+
.Trashes
19+
ehthumbs.db
20+
Thumbs.db
21+
22+
# IDE
23+
.vscode/settings.json
24+
.vscode/launch.json
25+
.vscode/extensions.json
26+
.history/
27+
28+
# TypeScript
29+
*.tsbuildinfo
30+
31+
# Local dev files
32+
*.local
33+
.env
34+
.env.local
35+
36+
# Temporary files
37+
*.tmp
38+
*.temp
39+
.lh/
40+
41+
# VS Code Extension packaging
42+
.vscode-test/
43+
.vscode-test/**
44+
45+
# Test coverage
46+
coverage/
47+
.nyc_output/
48+
49+
# Editor swap/backup files
50+
*~
51+
*.swp
52+
*.swo
53+
*.bak
54+
55+
# Mac system files
56+
.AppleDouble
57+
.LSOverride
58+
59+
# Windows system files
60+
Desktop.ini
61+
62+
# npm package logs
63+
package-lock.json
64+
pnpm-lock.yaml
65+
yarn.lock
66+

.vscodeignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Development files
2+
.vscode/
3+
.vscode-test/
4+
.github/
5+
src/**/*.ts
6+
src/**/*.map
7+
**/*.ts
8+
**/*.map
9+
**/tsconfig.json
10+
**/.eslintrc.json
11+
12+
# Tests and development
13+
test/
14+
src/test/
15+
out/test/
16+
*.test.*
17+
.nyc_output/
18+
19+
# Documentation and assets not needed in package
20+
docs/
21+
assets/icon-source.svg
22+
CONTRIBUTING.md
23+
DEVELOPMENT.md
24+
25+
# Build and development
26+
node_modules/
27+
npm-debug.log*
28+
yarn-debug.log*
29+
yarn-error.log*
30+
.lh/
31+
*.zip
32+
33+
# OS files
34+
**/.DS_Store
35+
.gitignore

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changelog
2+
_All notable changes to **Instant Count** are documented in this file.
3+
This project follows [Keep a Changelog](https://keepachangelog.com/) and
4+
adheres to [Semantic Versioning](https://semver.org/)._
5+
6+
---
7+
8+
## [1.0.0] – 2025-06-21 (first public release)
9+
10+
### Added
11+
- **Live status-bar counter** that updates as you select text.
12+
- **Numbered gutter badges** rendered only in (and near) the viewport.
13+
- **Quick-config panel** (click the counter) to toggle Case, Whole-word, Regex, Gutter Badges, Status Bar.
14+
- **Custom-rule engine**
15+
- `$TEXT` placeholder → escapes the current selection.
16+
- `$RAWTEXT` placeholder → inserts it raw for advanced patterns.
17+
- **Peek All Matches** (`Ctrl + Shift + 3`) and **Select All Matches** (`Ctrl + Shift + Alt + L`).
18+
- **Performance safeguards**
19+
- Chunked scanning & viewport badge rendering.
20+
- 500 ms regex timeout guard.
21+
- Built-in multiline (`m`) flag so `^` / `$` anchors work line-by-line.
22+
23+
### Fixed
24+
- Gutter badges could freeze after entering or clearing a custom rule; decorations now cleared without disposing their underlying types.
25+
- Regex anchors now honoured across multiple lines (`m` flag added by default).
26+
27+
### Docs
28+
- README with hero GIF, config-panel shot, and **before/after custom-rule** demo.
29+
- Quick-start, advanced recipes, configuration reference and FAQ (“Why not just use VS Code’s native search?”).
30+
31+
---

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Instant Count
2+
[![VS Marketplace](https://img.shields.io/visual-studio-marketplace/v/adnv3k.instant-count?label=VS%20Code%20Marketplace)](https://marketplace.visualstudio.com/items?itemName=adnv3k.instant-count)
3+
4+
> _Instantly count highlighted text, words, or fully-custom patterns – with live gutter badges, status-bar feedback, and one-click configuration._
5+
6+
![Main Demo](assets/screenshots/instant-count.gif)
7+
8+
---
9+
10+
## ✨ At a Glance
11+
| Feature | What it does |
12+
| :-- | :-- |
13+
| **Real-time Counter** | Status-bar number updates as you type or select |
14+
| **Numbered Badges** | Occurrence index drawn in the editor gutter |
15+
| **One-click Panel** | Click the counter to toggle case/word/regex, enter rules, etc. |
16+
| **Peek / Select-All** | View or multi-cursor-select every match in one command |
17+
| **Custom Rules** | `$TEXT` / `$RAWTEXT` placeholders turn any selection into a regex |
18+
| **Safe & Fast** | Chunked scanning, regex timeout guard, view-port badge rendering |
19+
20+
---
21+
22+
## 🚀 Quick Start
23+
1. **Install** from the VS Code Marketplace: `instant-count`.
24+
2. **Select** text (or just place the cursor on a word).
25+
3. Watch the **status-bar counter** and **gutter badges** appear.
26+
4. Hit `Ctrl + Shift + R` to open the quick-config panel.
27+
28+
---
29+
30+
## 🔍 Advanced Regex Recipes
31+
32+
Below are four ready-to-paste rule examples in the same format used inside the extension.
33+
34+
**Example 1: Untranslated i18n Keys**
35+
- **Select:** `t(`
36+
- **Regex Rule:** `t\(\s*"(en\.)[^"]+"\s*\)`
37+
- **Result:** Flags `t("en.some.key")` calls still hard-coded to English.
38+
39+
**Example 2: Left-over `console.*` Calls**
40+
- **Select:** `console`
41+
- **Regex Rule:** `(^|\s)(console\.(log|debug|warn|error))\s*\(`
42+
- **Result:** Catches any `console.log`, `.debug`, `.warn`, `.error` still lurking in code.
43+
44+
**Example 3: Duplicate Words**
45+
- **Select:** `the` (or any word)
46+
- **Regex Rule:** `\b$TEXT\s+$TEXT\b`
47+
- **Result:** Finds “the the”, “return return”, etc., regardless of the word you pick.
48+
49+
**Example 4: JSX Components Missing a Prop**
50+
- **Select:** `MyButton`
51+
- **Regex Rule:** `<MyButton\b(?![^>]*\bonClick=)`
52+
- **Result:** Highlights every `<MyButton …>` with no `onClick=` prop.
53+
54+
### Custom Rule in Action
55+
56+
| Before | After |
57+
|:--:|:--:|
58+
| ![Before](assets/screenshots/custom-rule-before.png) | ![After](assets/screenshots/custom-rule-after.png) |
59+
60+
---
61+
62+
## ⚙️ Configuration Reference
63+
64+
| Setting | Default | Description |
65+
| :-- | :--: | :-- |
66+
| `instant-count.caseSensitive` | `false` | Match case exactly |
67+
| `instant-count.wholeWord` | `false` | Add `\b…\b` boundaries |
68+
| `instant-count.useRegex` | `false` | Treat search pattern as regex |
69+
| `instant-count.showGutterBadges` | `true` | Toggle numbered badges |
70+
| `instant-count.showInStatusBar` | `true` | Toggle status-bar counter |
71+
| `instant-count.regexRules` | `""` | Custom rule with `$TEXT` / `$RAWTEXT` |
72+
73+
_Open **Command Palette → “Instant Count: Settings”** for the interactive panel._
74+
75+
---
76+
77+
## ⌨️ Useful Commands
78+
79+
| Command | Keybinding | What it does |
80+
| :-- | :--: | :-- |
81+
| Toggle Case | none | Switch case sensitivity |
82+
| Toggle Whole Word | none | Add/remove word boundaries |
83+
| Toggle Regex Mode | none | Literal ↔ regex |
84+
| Peek All Matches | `Ctrl + Shift + 3` | Open VS Code peek panel |
85+
| Select All Matches | `Ctrl + Shift + Alt + S` | Multi-cursor select |
86+
87+
---
88+
89+
## 🛡 Performance & Safety
90+
91+
* Chunked scanning keeps UI fluid even on **10 MB+** files.
92+
* Regex execution has a **500 ms timeout guard** to avoid catastrophic back-tracking freezes.
93+
* Badges are only rendered inside (and near) the view-port for zero scroll-lag.
94+
95+
---
96+
97+
## 🤝 Contributing
98+
99+
1. Fork the repo, `npm install`, press **F5** to launch the *Extension Host*.
100+
2. Submit pull-requests against the `dev` branch.
101+
3. All contributions are released under the MIT license.
102+
103+
---
104+
105+
## 📜 License
106+
107+
[MIT](LICENSE) © 2025 Ali Do
108+
109+
## 🤝 Contributing
110+
111+
PRs are welcome!
112+
1. Fork the repo · 2. `npm install` · 3. Press **F5** to launch the Extension Host · 4. Submit a pull-request to `main`.
113+
114+
## 🚀 Install
115+
116+
[![VS Marketplace](https://img.shields.io/visual-studio-marketplace/v/adnv3k.instant-count?label=Install%20from%20Marketplace&logo=visual-studio-code)](https://marketplace.visualstudio.com/items?itemName=adnv3k.instant-count)
117+
118+
---
119+
120+
> _Made with ♥ and a lot of regex._
37.4 KB
Loading
14 KB
Loading
54.4 KB
Loading

0 commit comments

Comments
 (0)