Skip to content

Commit 7512d8b

Browse files
committed
Indent whole file
1 parent cf20dee commit 7512d8b

File tree

11 files changed

+38
-26
lines changed

11 files changed

+38
-26
lines changed

client/src/editors/vscode/index.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ async function main() {
77

88
Editor.turnOn()
99
await wait(2000)
10+
1011
const info = await Editor.fileInfo()
1112

12-
await Editor.writeOnTerminal('node "' + info.fileName + '"')
13+
await Editor.write('hello doc')
14+
await Editor.indentSelection()
15+
16+
// await Editor.writeOnTerminal('node "' + info.fileName + '"')
1317
// await Editor.newLine(1)
1418
// console.log(await Editor.moveCursorTo('END_LINE'))
1519
// console.log(await Editor.moveCursorTo(null, undefined, 6))

spoken-vscode-driver/.eslintrc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
],
1111
"rules": {
1212
"@typescript-eslint/naming-convention": "warn",
13-
"@typescript-eslint/semi": "warn",
14-
"curly": "warn",
15-
"eqeqeq": "warn",
13+
"@typescript-eslint/semi": "off",
14+
"curly": "off",
15+
"eqeqeq": "off",
1616
"no-throw-literal": "warn",
1717
"semi": "off"
1818
}
34 Bytes
Binary file not shown.

spoken-vscode-driver/src/robot-vscode.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class RobotVscode implements Robot {
169169

170170
if (editor == null) return rej(e)
171171

172-
function MoveCursor(options: any) {
172+
function moveCursor(options: any) {
173173
if (options.value === 0) return res()
174174

175175
return vscode.commands.executeCommand('cursorMove', options).then(() => res())
@@ -180,12 +180,12 @@ class RobotVscode implements Robot {
180180
if (to === 'BEGIN_LINE' || to === 'END_LINE') {
181181
const { relative } = this.lineBoundaries(currentLine)
182182

183-
return MoveCursor({ to: relative[ to === 'BEGIN_LINE' ? 0 : 1 ] })
183+
return moveCursor({ to: relative[ to === 'BEGIN_LINE' ? 0 : 1 ] })
184184
}
185185

186186
// Move the cursor {leapSize} units to the right
187187
if (to === null) {
188-
return MoveCursor({ to: 'right', value: leapSize, by: 'character' })
188+
return moveCursor({ to: 'right', value: leapSize, by: 'character' })
189189
}
190190

191191
if (to === 'SYMBOL' && symbol != undefined) {
@@ -200,7 +200,7 @@ class RobotVscode implements Robot {
200200

201201
if (range == null) return rej('Match not found for symbol: ' + symbol)
202202

203-
return MoveCursor({ to: 'right', value: range[0], by: 'character' })
203+
return moveCursor({ to: 'right', value: range[0], by: 'character' })
204204
}
205205

206206
return rej(new Error('Unknown operation!'))
@@ -303,14 +303,20 @@ class RobotVscode implements Robot {
303303
* @param p2 Finish string[] (line, cursor)
304304
*/
305305
indentSelection = (
306-
p1: [string, string],
307-
p2: [string, string]
306+
p1?: [string, string],
307+
p2?: [string, string]
308308
) => new Promise<void | Error>((res, rej) => {
309309
try {
310310
const editor = vscode.window.activeTextEditor
311311

312312
if (editor == null) return rej(new Error('No active text editor'))
313313

314+
if (p1 == null || p2 == null) {
315+
return vscode.commands.executeCommand('editor.action.formatDocument', {}).then(a => {
316+
res()
317+
})
318+
}
319+
314320
p1[0] = p1[0] ?? editor.selection.active.line
315321
p2[0] = p2[0] ?? editor.selection.active.line
316322

spoken/playground.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ Math.max(5)
2121
// 1. More info on extension (v)
2222
// 2. More info on client (v)
2323
// 3. Add help section (v)
24-
// 3. write on blank file
24+
// 3. write on blank file (v)
25+
// 3. Indent whole file (v)
26+
// 3. remover linha
2527
// 4. Add button above mic informing lang and recording (v)
2628
// 5. escreva: letras
2729
// 5. escreva: . [ ] ( ) ? : ,

spoken/src/modules/typescript/condition/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function Condition(command: ConditionParsedArgs, editor: Editor, context:
1212
const line = await editor.getLine() as { _line: number }
1313

1414
await editor.write(text)
15-
await editor.indentSelection([line._line - 3, 0], [line._line + (otherwise ? 8 : 3), 0])
15+
await editor.indentSelection()
1616
await editor.goToLine(line._line as any)
1717

1818
return null

spoken/src/modules/typescript/function_call/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function FunctionCall(command: FunctionCallParsedArgs, editor: Editor, con
2626

2727
await editor.write(text)
2828

29-
return await editor.indentSelection([line._line - 1, 0], [line._line - 1, line.character])
29+
return await editor.indentSelection()
3030
}
3131

3232
const toArray = (arg: any | any[]) => Array.isArray(arg) ? arg : [arg]

spoken/src/modules/typescript/function_declaration/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function FunctionDeclaration(command: FunctionDeclarationParsedArgs, edito
2727

2828
await editor.write(text)
2929

30-
await editor.indentSelection([line._line - 3, 0], [line._line + 3, 0])
30+
await editor.indentSelection()
3131

3232
return await editor.goToLine(line._line as any)
3333
}

spoken/src/modules/typescript/repetition/impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function Repetition(command: RepetitionParsedArgs, editor: Editor, context
2323
const line = await editor.getLine() as { _line: number }
2424

2525
await editor.write(text)
26-
await editor.indentSelection([line._line - 3, 0], [line._line + 3, 0])
26+
await editor.indentSelection()
2727

2828
return await editor.goToLine(line._line as any)
2929
}

webapp/.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"trailingComma":"none",
33
"tabWidth": 4,
44
"semi": false,
5-
"singleQuote": true
5+
"singleQuote": true,
6+
"useTabs": true
67
}

0 commit comments

Comments
 (0)