Skip to content

Commit

Permalink
fix: Add CSpell Repl Terminal Profile (#3182)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Apr 14, 2024
1 parent 668b1ce commit 6840cf7
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Old settings viewer, to be removed
!packages/_settingsViewer/dist/webapp/*.{js,html,LICENSE.txt}

!packages/client/dist/**/*.js
!packages/client/dist/**/*.cjs
!packages/client/License.txt
!packages/client/package.json
!resources/**
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"onStartupFinished"
],
"type": "commonjs",
"main": "./packages/client/dist/extension.js",
"main": "./packages/client/dist/extension.cjs",
"capabilities": {
"virtualWorkspaces": {
"supported": "limited",
Expand Down Expand Up @@ -3418,7 +3418,15 @@
"title": "Reporting and Display",
"type": "object"
}
]
],
"terminal": {
"profiles": [
{
"title": "Spell Checker REPL",
"id": "cSpell.terminal-profile"
}
]
}
},
"workspaces": [
"docs",
Expand Down
2 changes: 1 addition & 1 deletion packages/_integrationTests/src/ExtensionApi.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/* @ts-ignore */
export type { OnSpellCheckDocumentStep } from '../../_server/dist/api.js';
export type { CSpellClient } from '../../client/dist/client/index.js';
export type { ExtensionApi } from '../../client/dist/extensionApi.js';
export type { ExtensionApi } from '../../client/dist/extensionApi.cjs';
8 changes: 4 additions & 4 deletions packages/client/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ async function buildAll() {
const configs = [
{
...optionsBase,
entryPoints: ['src/extension.ts'],
outfile: 'dist/extension.js',
entryPoints: ['src/extension.mts'],
outfile: 'dist/extension.cjs',
},
{
...optionsBase,
entryPoints: ['src/extensionApi.ts'],
outfile: 'dist/extensionApi.js',
entryPoints: ['src/extensionApi.cts'],
outfile: 'dist/extensionApi.cjs',
},
];

Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"bin": {
"build": "./build.mjs"
},
"main": "./dist/extension.js",
"main": "./dist/extension.cjs",
"scripts": {
"build": "npm run build:esbuild && npm run build:api && npm run build:tsc",
"build-production": "npm run clean-build-production",
Expand Down
7 changes: 7 additions & 0 deletions packages/client/src/extension.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { ExtensionContext } from 'vscode';
import type { ExtensionApi } from './extensionApi.cjs';

export async function activate(context: ExtensionContext): Promise<ExtensionApi> {
const extension = await import('./extension.mjs');
return extension.activate(context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@ import type { ExtensionContext } from 'vscode';
import * as vscode from 'vscode';
import { Utils as UriUtils } from 'vscode-uri';

import * as addWords from './addWords';
import { registerCspellInlineCompletionProviders } from './autocomplete';
import { CSpellClient } from './client';
import { registerSpellCheckerCodeActionProvider } from './codeAction';
import type { InjectableCommandHandlers } from './commands';
import * as commands from './commands';
import { updateDocumentRelatedContext } from './context';
import { SpellingExclusionsDecorator, SpellingIssueDecorator } from './decorate';
import * as di from './di';
import type { ExtensionApi } from './extensionApi';
import * as ExtensionRegEx from './extensionRegEx';
import * as settingsViewer from './infoViewer/infoView';
import { IssueTracker } from './issueTracker';
import { activateFileIssuesViewer, activateIssueViewer } from './issueViewer';
import * as modules from './modules';
import { createTerminal } from './repl/index.js';
import type { ConfigTargetLegacy, CSpellSettings } from './settings';
import * as settings from './settings';
import { sectionCSpell } from './settings';
import { getSectionName } from './settings/vsConfig';
import { initStatusBar } from './statusbar';
import { logErrors, silenceErrors } from './util/errors';
import { performance } from './util/perf';
import { activate as activateWebview } from './webview';
import * as addWords from './addWords.js';
import { registerCspellInlineCompletionProviders } from './autocomplete.js';
import { CSpellClient } from './client/index.js';
import { registerSpellCheckerCodeActionProvider } from './codeAction.js';
import type { InjectableCommandHandlers } from './commands.js';
import * as commands from './commands.js';
import { updateDocumentRelatedContext } from './context.js';
import { SpellingExclusionsDecorator, SpellingIssueDecorator } from './decorate.js';
import * as di from './di.js';
import type { ExtensionApi } from './extensionApi.cjs';
import * as ExtensionRegEx from './extensionRegEx/index.js';
import * as settingsViewer from './infoViewer/infoView.js';
import { IssueTracker } from './issueTracker.js';
import { activateFileIssuesViewer, activateIssueViewer } from './issueViewer/index.js';
import * as modules from './modules.js';
import { createTerminal, registerTerminalProfileProvider } from './repl/index.js';
import type { ConfigTargetLegacy, CSpellSettings } from './settings/index.js';
import * as settings from './settings/index.js';
import { sectionCSpell } from './settings/index.js';
import { getSectionName } from './settings/vsConfig.js';
import { initStatusBar } from './statusbar.js';
import { logErrors, silenceErrors } from './util/errors.js';
import { performance } from './util/perf.js';
import { activate as activateWebview } from './webview/index.js';

performance.mark('cspell_done_import');

Expand Down Expand Up @@ -110,6 +110,7 @@ export async function activate(context: ExtensionContext): Promise<ExtensionApi>
decorator,
decoratorExclusions,
registerSpellCheckerCodeActionProvider(issueTracker),
await registerTerminalProfileProvider(),

...commands.registerCommands(extensionCommand),

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/client/src/repl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ export async function createTerminal() {
const { createTerminal } = await import('./repl.mjs');
return createTerminal();
}

export async function registerTerminalProfileProvider() {
const { registerTerminalProfileProvider } = await import('./repl.mjs');
return registerTerminalProfileProvider();
}
8 changes: 8 additions & 0 deletions packages/client/src/repl/repl.mts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export function createTerminal() {
terminal.show();
}

export function registerTerminalProfileProvider(): vscode.Disposable {
return vscode.window.registerTerminalProfileProvider('cSpell.terminal-profile', {
provideTerminalProfile: () => {
return new vscode.TerminalProfile({ name: 'Spell Checker REPL', pty: new Repl() });
},
});
}

class Repl implements vscode.Disposable, vscode.Pseudoterminal {
readonly #emitterInput = new vscode.EventEmitter<string>();
readonly #emitterOutput = new vscode.EventEmitter<string>();
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/vscode/packageJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const sample = {
name: 'code-spell-checker',
description: 'Spelling checker for source code',
displayName: 'Code Spell Checker',
main: './packages/client/dist/extension.js',
main: './packages/client/dist/extension.cjs',
contributes: {
menus: {
'editor/context': [
Expand Down
2 changes: 1 addition & 1 deletion packages/client/tsconfig.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"emitDeclarationOnly": true
},
"files": ["src/extensionApi.ts"]
"files": ["src/extensionApi.cts"]
}
4 changes: 2 additions & 2 deletions packages/client/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "Node16",
"moduleResolution": "Node16",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "temp/dist"
},
"include": ["src"],
Expand Down

0 comments on commit 6840cf7

Please sign in to comment.