mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
JoinLines frontend
This commit is contained in:
parent
18918769ba
commit
8ad586a44e
5 changed files with 60 additions and 1 deletions
|
@ -51,6 +51,19 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
return new vscode.Selection(anchor, active)
|
||||
})
|
||||
})
|
||||
registerCommand('libsyntax-rust.joinLines', async () => {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let request: JoinLinesParams = {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
range: client.code2ProtocolConverter.asRange(editor.selection),
|
||||
}
|
||||
let response = await client.sendRequest<lc.TextEdit[]>("m/joinLines", request)
|
||||
let edits = client.protocol2CodeConverter.asTextEdits(response)
|
||||
let wsEdit = new vscode.WorkspaceEdit()
|
||||
wsEdit.set(editor.document.uri, edits)
|
||||
return vscode.workspace.applyEdit(wsEdit)
|
||||
})
|
||||
registerCommand('libsyntax-rust.parentModule', async () => {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
|
@ -237,6 +250,11 @@ interface FindMatchingBraceParams {
|
|||
offsets: lc.Position[];
|
||||
}
|
||||
|
||||
interface JoinLinesParams {
|
||||
textDocument: lc.TextDocumentIdentifier;
|
||||
range: lc.Range;
|
||||
}
|
||||
|
||||
interface PublishDecorationsParams {
|
||||
uri: string,
|
||||
decorations: Decoration[],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue