Skip to content

Commit b67e7f7

Browse files
committed
address feedback
1 parent 895e218 commit b67e7f7

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/vs/workbench/contrib/terminal/browser/terminalSpeechToText.ts

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,35 @@ import { IXtermMarker } from 'vs/platform/terminal/common/capabilities/capabilit
1717
import { ThemeIcon } from 'vs/base/common/themables';
1818
import { Codicon } from 'vs/base/common/codicons';
1919

20+
const symbolMap: { [key: string]: string } = {
21+
'Ampersand': '&',
22+
'ampersand': '&',
23+
'Dollar': '$',
24+
'dollar': '$',
25+
'Percent': '%',
26+
'percent': '%',
27+
'Asterisk': '*',
28+
'asterisk': '*',
29+
'Plus': '+',
30+
'plus': '+',
31+
'Equals': '=',
32+
'equals': '=',
33+
'Exclamation': '!',
34+
'exclamation': '!',
35+
'Slash': '/',
36+
'slash': '/',
37+
'Backslash': '\\',
38+
'backslash': '\\',
39+
'Dot': '.',
40+
'dot': '.',
41+
'Period': '.',
42+
'period': '.',
43+
'Quote': '\'',
44+
'quote': '\'',
45+
'double quote': '"',
46+
'Double quote': '"',
47+
};
48+
2049
export class TerminalSpeechToTextSession extends Disposable {
2150
private _input: string = '';
2251
private _ghostText: IDecoration | undefined;
@@ -111,37 +140,9 @@ export class TerminalSpeechToTextSession extends Disposable {
111140
private _updateInput(e: ISpeechToTextEvent): void {
112141
if (e.text) {
113142
let input = e.text.replaceAll(/[.,?;!]/g, '');
114-
const symbolMap: { [key: string]: string } = {
115-
'Ampersand': '&',
116-
'ampersand': '&',
117-
'Dollar': '$',
118-
'dollar': '$',
119-
'Percent': '%',
120-
'percent': '%',
121-
'Asterisk': '*',
122-
'asterisk': '*',
123-
'Plus': '+',
124-
'plus': '+',
125-
'Equals': '=',
126-
'equals': '=',
127-
'Exclamation': '!',
128-
'exclamation': '!',
129-
'Slash': '/',
130-
'slash': '/',
131-
'Backslash': '\\',
132-
'backslash': '\\',
133-
'Dot': '.',
134-
'dot': '.',
135-
'Period': '.',
136-
'period': '.',
137-
'Quote': '\'',
138-
'quote': '\'',
139-
'double quote': '"',
140-
'Double quote': '"',
141-
};
142143

143-
for (const symbol in symbolMap) {
144-
const regex: RegExp = new RegExp(symbol);
144+
for (const symbol of Object.values(symbolMap)) {
145+
const regex: RegExp = new RegExp(symbol + '\b');
145146
input = input.replace(regex, symbolMap[symbol]);
146147
}
147148
this._input = ' ' + input;

0 commit comments

Comments
 (0)