Skip to content

Commit da0174a

Browse files
committed
More consistently use the Position type
1 parent d50cbf7 commit da0174a

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

ui/frontend/AdvancedEditor.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
22
import { connect } from 'react-redux';
33

44
import State from './state';
5-
import { CommonEditorProps, Crate, Edition, Focus, PairCharacters } from './types';
5+
import { CommonEditorProps, Crate, Edition, Focus, PairCharacters, Position } from './types';
66

77
type Ace = typeof import('ace-builds');
88
type AceEditor = import('ace-builds').Ace.Editor;
@@ -63,10 +63,7 @@ interface AdvancedEditorProps {
6363
execute: () => any;
6464
keybinding?: string;
6565
onEditCode: (_: string) => any;
66-
position: {
67-
line: number;
68-
column: number;
69-
};
66+
position: Position;
7067
theme: string;
7168
crates: Crate[];
7269
focus?: Focus;
@@ -297,10 +294,7 @@ interface AdvancedEditorAsyncProps {
297294
execute: () => any;
298295
keybinding?: string;
299296
onEditCode: (_: string) => any;
300-
position: {
301-
line: number;
302-
column: number;
303-
};
297+
position: Position;
304298
theme: string;
305299
crates: Crate[];
306300
focus?: Focus;

ui/frontend/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useSelector, useDispatch } from 'react-redux';
33

44
import * as actions from './actions';
55
import AdvancedEditor from './AdvancedEditor';
6-
import { CommonEditorProps, Editor as EditorType } from './types';
6+
import { CommonEditorProps, Editor as EditorType, Position } from './types';
77
import { State } from './reducers';
88

99
class SimpleEditor extends React.PureComponent<CommonEditorProps> {
@@ -37,7 +37,7 @@ class SimpleEditor extends React.PureComponent<CommonEditorProps> {
3737
this.gotoPosition(prevProps.position, this.props.position);
3838
}
3939

40-
private gotoPosition(oldPosition, newPosition) {
40+
private gotoPosition(oldPosition: Position, newPosition: Position) {
4141
const editor = this._editor;
4242

4343
if (!newPosition || !editor) { return; }

ui/frontend/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export const addImport = (code: string) =>
429429
export const enableFeatureGate = (featureGate: string) =>
430430
createAction(ActionType.EnableFeatureGate, { featureGate });
431431

432-
export const gotoPosition = (line, column) =>
432+
export const gotoPosition = (line: string | number, column: string | number) =>
433433
createAction(ActionType.GotoPosition, { line: +line, column: +column });
434434

435435
const requestFormat = () =>

0 commit comments

Comments
 (0)