Format vscode extension and add npm run fix

This commit is contained in:
Adolfo Ochagavía 2018-10-09 22:56:15 +02:00
parent 31c8ebb743
commit f2d719b24a
4 changed files with 29 additions and 14 deletions

View file

@ -1,7 +1,10 @@
import * as vscode from 'vscode';
import * as lc from 'vscode-languageclient';
import { Server } from '../server';
import { handle as applySourceChange, SourceChange } from './apply_source_change';
import {
handle as applySourceChange,
SourceChange
} from './apply_source_change';
interface OnEnterParams {
textDocument: lc.TextDocumentIdentifier;
@ -10,12 +13,18 @@ interface OnEnterParams {
export async function handle(event: { text: string }): Promise<boolean> {
const editor = vscode.window.activeTextEditor;
if (editor == null || editor.document.languageId !== 'rust' || event.text !== '\n') {
if (
editor == null ||
editor.document.languageId !== 'rust' ||
event.text !== '\n'
) {
return false;
}
const request: OnEnterParams = {
textDocument: { uri: editor.document.uri.toString() },
position: Server.client.code2ProtocolConverter.asPosition(editor.selection.active),
position: Server.client.code2ProtocolConverter.asPosition(
editor.selection.active
)
};
const change = await Server.client.sendRequest<undefined | SourceChange>(
'm/onEnter',
@ -25,5 +34,5 @@ export async function handle(event: { text: string }): Promise<boolean> {
return false;
}
await applySourceChange(change);
return true
return true;
}