Skip to content

Commit

Permalink
dev: Add Commands (#3548)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Aug 19, 2024
1 parent e574125 commit d9dfccc
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 1 deletion.
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,42 @@
"title": "Show Spell Checker Actions Menu",
"shortTitle": "Spell Checker Actions",
"icon": "$(list-unordered)"
},
{
"command": "cSpell.supportRequest",
"category": "Spell",
"title": "Request Support with the Spell Checker",
"icon": "$(github)"
},
{
"command": "cSpell.reportIssue",
"category": "Spell",
"title": "Report an Issue with the Spell Checker",
"icon": "$(github)"
},
{
"command": "cSpell.about",
"category": "Spell",
"title": "About the Spell Checker",
"icon": "$(home)"
},
{
"command": "cSpell.releaseNotes",
"category": "Spell",
"title": "Show Spell Checker Release Notes",
"icon": "$(heart)"
},
{
"command": "cSpell.sponsor",
"category": "Spell",
"title": "Sponsor the Spell Checker",
"icon": "$(heart)"
},
{
"command": "cSpell.sponsorshipRequest",
"category": "Spell",
"title": "Become a Sponsor of the Spell Checker",
"icon": "$(heart)"
}
],
"languages": [
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/commands.mts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
targetsForUri,
targetsFromConfigurationTarget,
} from './settings/targetHelpers.mjs';
import { about, callForSponsors, releaseNotes, reportIssue, sponsor, supportRequest } from './support/index.mjs';
import { experimentWithSymbols } from './symbolServer/index.mjs';
import { findNotebookCell } from './util/documentUri.js';
import { catchErrors, handleErrors } from './util/errors.js';
Expand Down Expand Up @@ -182,6 +183,13 @@ export const commandHandlers = {
'cSpell.restart': handleRestart,
'cSpell.reload': handleReload,

'cSpell.supportRequest': supportRequest,
'cSpell.reportIssue': reportIssue,
'cSpell.about': about,
'cSpell.sponsor': sponsor,
'cSpell.sponsorshipRequest': callForSponsors,
'cSpell.releaseNotes': releaseNotes,

// Deprecated Commands
'cSpell.enableLanguage': enableLanguageIdCmd,
'cSpell.disableLanguage': disableLanguageIdCmd,
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/di.mts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export function getClient(): CSpellClient {
return get('client');
}

export function getExtensionContext(): ExtensionContext {
return get('extensionContext');
}

export function getIssueTracker(): IssueTracker {
return get('issueTracker');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/extension.mts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ modules.init();

export async function activate(context: ExtensionContext): Promise<ExtensionApi> {
performance.mark('cspell_activate_start');
di.set('extensionContext', context);

const logOutput = vscode.window.createOutputChannel('Code Spell Checker', { log: true });
const dLogger = bindLoggerToOutput(logOutput);
Expand All @@ -58,7 +59,6 @@ export async function activate(context: ExtensionContext): Promise<ExtensionApi>
context.subscriptions.push(client, logOutput, dLogger);

di.set('client', client);
di.set('extensionContext', context);

ExtensionRegEx.activate(context, client);

Expand Down
35 changes: 35 additions & 0 deletions packages/client/src/support/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { commands, Uri } from 'vscode';

import { getExtensionContext } from '../di.mjs';

export async function about(): Promise<void> {
const uriReadme = Uri.joinPath(getExtensionContext().extensionUri, 'resources/pages/About the Spell Checker.md');
return commands.executeCommand('markdown.showPreview', null, [uriReadme], { lock: true });
}

export function supportRequest(): Promise<void> {
return openMarkdown('resources/pages/Spell Checker Support Request.md');
}

export function reportIssue(): Promise<void> {
return openMarkdown('resources/pages/Spell Checker Report Issue.md');
}

export function sponsor(): Promise<void> {
return openMarkdown('resources/pages/Sponsor the Spell Checker.md');
}

export function callForSponsors(): Promise<void> {
return openMarkdown('resources/pages/Sponsor the Spell Checker.md');
}

export function releaseNotes(): Promise<void> {
return openMarkdown('resources/pages/Spell Checker Release Notes.md');
}

async function openMarkdown(uri: Uri | string): Promise<void> {
if (typeof uri === 'string') {
uri = Uri.joinPath(getExtensionContext().extensionUri, uri);
}
return commands.executeCommand('markdown.showPreview', null, [uri], { lock: true });
}
1 change: 1 addition & 0 deletions resources/pages/About the Spell Checker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# About
7 changes: 7 additions & 0 deletions resources/pages/Spell Checker Release Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Release Notes

For detailed release notes see [Spell Checker Releases](https://github.com/streetsidesoftware/vscode-spell-checker/releases).

## v4.0.0

Starting with v4, the release notes for major features will be included in the extension.
8 changes: 8 additions & 0 deletions resources/pages/Spell Checker Report Issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Report an Issue

## How to Report an Issue

1. Missing Words: Open an issue with [CSpell Dictionaries](https://github.com/streetsidesoftware/cspell-dicts/issues)
1. The Spell Checker is not work as expected: [Open an Issue](https://github.com/streetsidesoftware/vscode-spell-checker/issues)

[test command](command:workbench.action.closeActiveEditor)
1 change: 1 addition & 0 deletions resources/pages/Spell Checker Support Request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Support Request
1 change: 1 addition & 0 deletions resources/pages/Sponsor the Spell Checker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Sponsor

0 comments on commit d9dfccc

Please sign in to comment.