From 69de7e2fd71c3a808f0ac856d7b105eeb210f169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Sun, 7 Oct 2018 22:44:25 +0200 Subject: Refactor vscode extension --- editors/code/src/commands/join_lines.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 editors/code/src/commands/join_lines.ts (limited to 'editors/code/src/commands/join_lines.ts') diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts new file mode 100644 index 000000000..7ae7b9d76 --- /dev/null +++ b/editors/code/src/commands/join_lines.ts @@ -0,0 +1,21 @@ +import * as vscode from 'vscode'; + +import { TextDocumentIdentifier, Range } from "vscode-languageclient"; +import { Server } from '../server'; +import { handle as applySourceChange, SourceChange } from './apply_source_change'; + +interface JoinLinesParams { + textDocument: TextDocumentIdentifier; + range: Range; +} + +export async function handle() { + let editor = vscode.window.activeTextEditor + if (editor == null || editor.document.languageId != "rust") return + let request: JoinLinesParams = { + textDocument: { uri: editor.document.uri.toString() }, + range: Server.client.code2ProtocolConverter.asRange(editor.selection), + } + let change = await Server.client.sendRequest("m/joinLines", request) + await applySourceChange(change) +} -- cgit v1.2.3 From 4d62cfccbb8281f33b6f894df07e7316a9d45bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Sun, 7 Oct 2018 22:59:02 +0200 Subject: Apply tslint suggestions, round one --- editors/code/src/commands/join_lines.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'editors/code/src/commands/join_lines.ts') diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts index 7ae7b9d76..80ad4460b 100644 --- a/editors/code/src/commands/join_lines.ts +++ b/editors/code/src/commands/join_lines.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; -import { TextDocumentIdentifier, Range } from "vscode-languageclient"; +import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; import { Server } from '../server'; import { handle as applySourceChange, SourceChange } from './apply_source_change'; @@ -10,12 +10,12 @@ interface JoinLinesParams { } export async function handle() { - let editor = vscode.window.activeTextEditor - if (editor == null || editor.document.languageId != "rust") return - let request: JoinLinesParams = { - textDocument: { uri: editor.document.uri.toString() }, + const editor = vscode.window.activeTextEditor; + if (editor == null || editor.document.languageId != 'rust') { return; } + const request: JoinLinesParams = { range: Server.client.code2ProtocolConverter.asRange(editor.selection), - } - let change = await Server.client.sendRequest("m/joinLines", request) - await applySourceChange(change) + textDocument: { uri: editor.document.uri.toString() }, + }; + const change = await Server.client.sendRequest('m/joinLines', request); + await applySourceChange(change); } -- cgit v1.2.3 From 62b1b05a0d9dd021f98352b6229e48e0d8b94f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20Ochagav=C3=ADa?= Date: Mon, 8 Oct 2018 20:18:55 +0200 Subject: Fix remaining tslint suggestions --- editors/code/src/commands/join_lines.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'editors/code/src/commands/join_lines.ts') diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts index 80ad4460b..526b698cc 100644 --- a/editors/code/src/commands/join_lines.ts +++ b/editors/code/src/commands/join_lines.ts @@ -11,7 +11,7 @@ interface JoinLinesParams { export async function handle() { const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId != 'rust') { return; } + if (editor == null || editor.document.languageId !== 'rust') { return; } const request: JoinLinesParams = { range: Server.client.code2ProtocolConverter.asRange(editor.selection), textDocument: { uri: editor.document.uri.toString() }, -- cgit v1.2.3