Skip to content

Commit 62de7fc

Browse files
authored
Merge pull request #2 from soderlind/intelisence
Add Intelisence
2 parents 070f23f + 68702e7 commit 62de7fc

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0/) and this project adheres to Semantic Versioning (https://semver.org/spec/v2.0.0.html).
66

7+
## [0.1.3] - 2025-10-04
8+
### Added
9+
- Section heading IntelliSense completion provider (type `==` then space for valid section suggestions)
10+
711
## [0.1.1] - 2025-10-03
812
### Added
913
- wordpress.org tabbed preview theme (Description, Installation, FAQ, Screenshots, Changelog, Reviews placeholder)
@@ -27,4 +31,5 @@ The format is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0/) a
2731
- Context menu integration across explorer, editor tab, and editor content
2832
- Custom parser for WordPress readme formatting (FAQ, changelog headers, etc.)
2933

34+
[0.1.3]: https://github.com/soderlind/wordpress-readme-preview/compare/v0.1.1...v0.1.3
3035
[0.1.1]: https://github.com/soderlind/wordpress-readme-preview/compare/v0.1.0...v0.1.1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A Visual Studio Code extension that provides live preview and validation for Wor
1616
**False Positive Prevention** - Accurate detection without hallucinated errors
1717
**Tabbed wordpress.org Layout** - Authentic multi-tab presentation (Description, Installation, FAQ, Screenshots, Changelog)
1818
**Accessible Screenshot Gallery** - Keyboard & screen reader friendly with thumbnails
19+
**Section Heading IntelliSense** - Type `==` then space for valid section name completions
1920

2021
![Alt text](media/example.png)
2122

example/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Stable tag: 1.5.3
77
License: GPLv2 or later
88
License URI: https://www.gnu.org/licenses/gpl-2.0.html
99

10+
1011
Run wp-cron on all public sites in a multisite network (REST API based). Formerly known as DSS Cron.
1112

1213
== Description ==

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "wordpress-readme-preview",
33
"displayName": "WordPress Readme Preview",
44
"description": "Preview WordPress readme.txt files with accurate rendering and validation",
5-
"version": "0.1.1",
5+
"version": "0.1.3",
66
"publisher": "persoderlind",
77
"engines": {
88
"vscode": "^1.74.0"

src/extension.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,42 @@ export function activate(context: vscode.ExtensionContext) {
7272
]
7373
});
7474

75+
// Completion provider for section headings after '==' at start of line
76+
const SECTION_HEADINGS = [
77+
'Description',
78+
'Installation',
79+
'Frequently Asked Questions',
80+
'Screenshots',
81+
'Changelog',
82+
'Upgrade Notice'
83+
];
84+
85+
const sectionCompletionProvider = vscode.languages.registerCompletionItemProvider(
86+
{ language: 'readme-txt', scheme: 'file' },
87+
{
88+
provideCompletionItems(document, position) {
89+
const line = document.lineAt(position).text;
90+
const prefix = line.substring(0, position.character);
91+
// Trigger only if line starts with optional whitespace then '==' and no closing '==' yet
92+
const match = prefix.match(/^\s*==\s?(.*)$/);
93+
if (!match) {
94+
return undefined;
95+
}
96+
// If closing '==' already present, do not offer
97+
if (/==\s.*==/.test(line)) {
98+
return undefined;
99+
}
100+
return SECTION_HEADINGS.map(h => {
101+
const item = new vscode.CompletionItem(h, vscode.CompletionItemKind.Module);
102+
item.insertText = `== ${h} ==`;
103+
item.detail = 'WordPress readme section';
104+
item.sortText = '0_' + h;
105+
return item;
106+
});
107+
},
108+
}, ' '
109+
);
110+
75111
// Add status bar item
76112
const statusBarItem = createStatusBarItem();
77113
updateStatusBarItem(statusBarItem);
@@ -100,6 +136,7 @@ export function activate(context: vscode.ExtensionContext) {
100136
onDidChangeActiveTextEditor,
101137
onDidChangeTextDocument,
102138
readmeLanguageConfig,
139+
sectionCompletionProvider,
103140
statusBarItem,
104141
previewProvider,
105142
diagnosticCollection

0 commit comments

Comments
 (0)