Skip to content

Commit 1dc5e58

Browse files
Addressed PR#1453 comments
1 parent b0c8bc7 commit 1dc5e58

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

arduino-ide-extension/src/browser/serial/monitor/serial-monitor-send-input.tsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import { MonitorModel } from '../../monitor-model';
77
import { Unknown } from '../../../common/nls';
88

99
class RingList {
10-
protected ring: string[];
11-
protected size: number;
12-
protected begin: number;
13-
protected index: number;
14-
protected end: number;
10+
private ring: string[];
11+
private size: number;
12+
private begin: number;
13+
private index: number;
14+
private end: number;
1515

1616
constructor(size: number = 100) {
17-
this.Init = this.Init.bind(this);
18-
this.Push = this.Push.bind(this);
19-
this.Prev = this.Prev.bind(this);
20-
this.Next = this.Next.bind(this);
21-
this.Init(size);
17+
this.init = this.init.bind(this);
18+
this.push = this.push.bind(this);
19+
this.prev = this.prev.bind(this);
20+
this.next = this.next.bind(this);
21+
this.init(size);
2222
}
2323

24-
public Init(size: number = 100)
24+
private init(size: number = 100)
2525
{
2626
this.ring = [];
2727
this.size = (size > 0) ? size : 1;
@@ -30,7 +30,7 @@ class RingList {
3030
this.end = -1;
3131
}
3232

33-
public Push(val: string): number {
33+
push(val: string): number {
3434
this.end++;
3535
if (this.ring.length >= this.size)
3636
{
@@ -49,9 +49,9 @@ class RingList {
4949
return this.index;
5050
}
5151

52-
public Prev(): string {
52+
prev(): string {
5353
if (this.ring.length < 1) {
54-
return "";
54+
return '';
5555
}
5656

5757
if (this.index !== this.begin) {
@@ -61,9 +61,9 @@ class RingList {
6161
return this.ring[this.index];
6262
}
6363

64-
public Next(): string {
64+
next(): string {
6565
if (this.ring.length < 1) {
66-
return "";
66+
return '';
6767
}
6868

6969
if (this.index !== this.end) {
@@ -72,7 +72,6 @@ class RingList {
7272

7373
return this.ring[this.index];
7474
}
75-
7675
}
7776

7877
export namespace SerialMonitorSendInput {
@@ -183,14 +182,16 @@ export class SerialMonitorSendInput extends React.Component<
183182
// NOTE: order of operations is critical here. Push the current state.text
184183
// onto the history stack before sending. After sending, state.text is empty
185184
// and you'd end up pushing '' onto the history stack.
186-
if (this.state.text.length > 0) this.state.history.Push(this.state.text);
185+
if (this.state.text.length > 0) {
186+
this.state.history.push(this.state.text);
187+
}
187188
this.onSend();
188-
} else
189-
if (key === Key.ARROW_UP) {
190-
this.setState({ text: this.state.history.Prev()});
191-
} else
192-
if (key === Key.ARROW_DOWN) {
193-
this.setState({ text: this.state.history.Next()});
189+
}
190+
else if (key === Key.ARROW_UP) {
191+
this.setState({ text: this.state.history.prev()});
192+
}
193+
else if (key === Key.ARROW_DOWN) {
194+
this.setState({ text: this.state.history.next()});
194195
}
195196
}
196197
}

0 commit comments

Comments
 (0)