Skip to content

Commit 458fd32

Browse files
committed
Enforce safer use of vscode.WorkspaceConfiguration
1 parent d0e33d2 commit 458fd32

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/actions/commands/actions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ abstract class CommandScrollAndMoveCursor extends BaseCommand {
534534

535535
public async exec(position: Position, vimState: VimState): Promise<void> {
536536
const { visibleRanges } = vimState.editor;
537-
const smoothScrolling = configuration.getConfiguration('editor').smoothScrolling;
537+
const smoothScrolling = configuration
538+
.getConfiguration('editor')
539+
.get<boolean>('smoothScrolling', false);
538540
const moveLines = (vimState.actionCount || 1) * this.getNumLines(vimState);
539541

540542
let scrollLines = moveLines;

src/configuration/configuration.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import {
2020
import * as packagejson from '../../package.json';
2121
import { SUPPORT_VIMRC } from 'platform/constants';
2222

23+
// https://stackovrflow.com/questions/51465182/how-to-remove-index-signature-using-mapped-types/51956054#51956054
24+
type RemoveIndex<T> = {
25+
[P in keyof T as string extends P ? never : number extends P ? never : P]: T[P];
26+
};
27+
2328
export const extensionVersion = packagejson.version;
2429

2530
/**
@@ -182,7 +187,7 @@ class Configuration implements IConfiguration {
182187
return validatorResults;
183188
}
184189

185-
getConfiguration(section: string = ''): vscode.WorkspaceConfiguration {
190+
getConfiguration(section: string = ''): RemoveIndex<vscode.WorkspaceConfiguration> {
186191
const document = vscode.window.activeTextEditor?.document;
187192
const resource = document ? { uri: document.uri, languageId: document.languageId } : undefined;
188193
return vscode.workspace.getConfiguration(section, resource);

0 commit comments

Comments
 (0)