Re-enable format_selections for a single selection range

pull/4678/head
Blaž Hrastnik 2 years ago
parent dee5b2a983
commit d4f5cab7b5
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -3748,7 +3748,7 @@ fn format_selections(cx: &mut Context) {
let (view, doc) = current!(cx.editor); let (view, doc) = current!(cx.editor);
// via lsp if available // via lsp if available
// else via tree-sitter indentation calculations // TODO: else via tree-sitter indentation calculations
let language_server = match doc.language_server() { let language_server = match doc.language_server() {
Some(language_server) => language_server, Some(language_server) => language_server,
@ -3761,33 +3761,34 @@ fn format_selections(cx: &mut Context) {
.map(|range| range_to_lsp_range(doc.text(), *range, language_server.offset_encoding())) .map(|range| range_to_lsp_range(doc.text(), *range, language_server.offset_encoding()))
.collect(); .collect();
// TODO: all of the TODO's and commented code inside the loop, if ranges.len() != 1 {
// to make this actually work. cx.editor
for _range in ranges { .set_error("format_selections only supports a single selection for now");
let _language_server = match doc.language_server() { return;
Some(language_server) => language_server, }
None => return,
};
// TODO: handle fails // TODO: handle fails
// TODO: concurrent map // TODO: concurrent map over all ranges
// TODO: need to block to get the formatting let range = ranges[0];
// let edits = block_on(language_server.text_document_range_formatting( let edits = tokio::task::block_in_place(|| {
// doc.identifier(), helix_lsp::block_on(language_server.text_document_range_formatting(
// range, doc.identifier(),
// lsp::FormattingOptions::default(), range,
// )) lsp::FormattingOptions::default(),
// .unwrap_or_default(); None,
))
})
.unwrap_or_default();
// let transaction = helix_lsp::util::generate_transaction_from_edits( let transaction = helix_lsp::util::generate_transaction_from_edits(
// doc.text(), doc.text(),
// edits, edits,
// language_server.offset_encoding(), language_server.offset_encoding(),
// ); );
// apply_transaction(&transaction, doc, view); apply_transaction(&transaction, doc, view);
}
} }
fn join_selections_inner(cx: &mut Context, select_space: bool) { fn join_selections_inner(cx: &mut Context, select_space: bool) {

Loading…
Cancel
Save