Skip to content

Commit 3877ead

Browse files
authored
Feature/debug adapter file selection improvements (#60)
* Enhance debug adapter file selection with improved path handling and UI updates * Fix formatting in openFile button click handler for consistency * Improve file opening tests with normalized URI path validation * Fix copyright year and enhance file selection handling in tests * Improve file selection handling by replacing targetElementId with requestId in SELECT_FILE messages * Enhance file handling and improve accessibility in Manage Solution components
1 parent 28afda5 commit 3877ead

8 files changed

Lines changed: 226 additions & 137 deletions

File tree

src/desktop/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export const activate = async (context: ExtensionContext): Promise<CsolutionExte
224224
commandsProvider,
225225
configurationProvider,
226226
csolutionService,
227+
externalFileOpener,
227228
);
228229
context.subscriptions.push(window.registerCustomEditorProvider(
229230
ManageSolutionCustomEditorProvider.viewType,

src/views/common/components/cmsis-codicon.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,35 @@ const CMSIS_CODICON_CODEPOINTS = {
2424

2525
export type CmsisCodiconName = keyof typeof CMSIS_CODICON_CODEPOINTS;
2626

27-
type Props = {
28-
name: CmsisCodiconName;
29-
title?: string;
30-
className?: string;
31-
style?: React.CSSProperties;
27+
type Props = React.ComponentPropsWithoutRef<'span'> & {
28+
name: CmsisCodiconName | string;
3229
fontFamily?: string; // default is your custom webview font
3330
};
3431

3532
export const CmsisCodicon: React.FC<Props> = ({
3633
name,
37-
title,
3834
className,
3935
style,
4036
fontFamily = 'cmsis-codicon',
37+
...spanProps
4138
}) => {
42-
const codepoint = CMSIS_CODICON_CODEPOINTS[name];
39+
const codepoint = CMSIS_CODICON_CODEPOINTS[name as CmsisCodiconName];
40+
if (codepoint !== undefined) {
41+
return (
42+
<span
43+
{...spanProps}
44+
className={className ?? ''}
45+
style={{ fontFamily, display: 'inline-block', lineHeight: 1, ...style }}
46+
>
47+
{String.fromCodePoint(codepoint)}
48+
</span>
49+
);
50+
}
4351
return (
4452
<span
45-
title={title}
46-
className={className}
47-
style={{ fontFamily, display: 'inline-block', lineHeight: 1, ...style }}
48-
>
49-
{String.fromCodePoint(codepoint)}
50-
</span>
53+
{...spanProps}
54+
className={`codicon codicon-${name}${className ? ` ${className}` : ''}`}
55+
style={{ display: 'inline-block', lineHeight: 1, ...style }}
56+
/>
5157
);
5258
};

src/views/manage-solution/manage-solution-custom-editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { ConfigurationProvider } from '../../vscode-api/configuration-provider';
2626
import { CsolutionService } from '../../json-rpc/csolution-rpc-client';
2727
import { SolutionData } from './view/state/manage-solution-state';
2828
import { COMMAND_OPEN_SOLUTION } from '../../solutions/active-solution-tracker';
29+
import { IOpenFileExternal } from '../../open-file-external-if';
2930

3031
type EditEntry = {
3132
label: string;
@@ -118,6 +119,7 @@ export class ManageSolutionCustomEditorProvider implements vscode.CustomEditorPr
118119
private readonly commandsProvider: CommandsProvider,
119120
private readonly configurationProvider: ConfigurationProvider,
120121
private readonly csolutionService: CsolutionService,
122+
private readonly openFileExternal: IOpenFileExternal,
121123
) { }
122124

123125
private getOrCreateWebviewMain(): ManageSolutionWebviewMain {
@@ -134,6 +136,7 @@ export class ManageSolutionCustomEditorProvider implements vscode.CustomEditorPr
134136
this.context,
135137
this.solutionManager,
136138
this.commandsProvider,
139+
this.openFileExternal,
137140
this.configurationProvider,
138141
this.csolutionService,
139142
(label, before, after) => this.activeDocument?.recordEdit(label, before, after),

src/views/manage-solution/manage-solution-webview-main.factories.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import { solutionManagerFactory } from '../../solutions/solution-manager.factori
2525
import { DataManager } from '../../data-manager/data-manager';
2626
import { DebugAdaptersYamlFile } from '../../debug/debug-adapters-yaml-file';
2727
import { configurationProviderFactory } from '../../vscode-api/configuration-provider.factories';
28+
import { IOpenFileExternal } from '../../open-file-external-if';
29+
import { openFileExternalFactory } from '../../open-file-external.factories';
2830
import { ETextFileResult } from '../../generic/text-file';
2931
import { SolutionData } from './view/state/manage-solution-state';
3032
import { ManageSolutionController } from './manage-solution-controller';
@@ -36,6 +38,7 @@ export type ManageSolutionWebviewMainFactoryOptions = {
3638
commandsProvider?: MockCommandsProvider;
3739
dataManager?: DataManager;
3840
debugAdaptersYmlFile?: DebugAdaptersYamlFile;
41+
openFileExternal?: IOpenFileExternal;
3942
configurationProvider?: ReturnType<typeof configurationProviderFactory>;
4043
csolutionService?: CsolutionService,
4144
onEdit?: (label: string, before: SolutionData, after: SolutionData) => void,
@@ -76,6 +79,7 @@ export function manageSolutionWebviewMainFactory(options?: ManageSolutionWebview
7679
{ subscriptions: [] } as unknown as vscode.ExtensionContext,
7780
options?.solutionManager ?? solutionManagerFactory(),
7881
options?.commandsProvider ?? commandsProviderFactory(),
82+
options?.openFileExternal ?? openFileExternalFactory(),
7983
options?.configurationProvider ?? configurationProviderFactory(),
8084
options?.csolutionService ?? jest.mocked<CsolutionService>({
8185
getDeviceList: async function (_args: GetDeviceListParams): Promise<DeviceList> { throw new Error('Function not implemented.'); },

0 commit comments

Comments
 (0)