mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-17 18:28:44 +00:00
Merge #8950
8950: minor: align import style with styleguide r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
e0864c9c15
2 changed files with 6 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use hir::{Adt, Semantics, Type};
|
use hir::Semantics;
|
||||||
use syntax::ast::{self, make};
|
use syntax::ast::{self, make};
|
||||||
|
|
||||||
use crate::RootDatabase;
|
use crate::RootDatabase;
|
||||||
|
@ -20,9 +20,9 @@ impl TryEnum {
|
||||||
const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result];
|
const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result];
|
||||||
|
|
||||||
/// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`.
|
/// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`.
|
||||||
pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &Type) -> Option<TryEnum> {
|
pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
|
||||||
let enum_ = match ty.as_adt() {
|
let enum_ = match ty.as_adt() {
|
||||||
Some(Adt::Enum(it)) => it,
|
Some(hir::Adt::Enum(it)) => it,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
TryEnum::ALL.iter().find_map(|&var| {
|
TryEnum::ALL.iter().find_map(|&var| {
|
||||||
|
|
|
@ -56,6 +56,9 @@ export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vs
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (selections.length > 0) editor.selections = selections;
|
if (selections.length > 0) editor.selections = selections;
|
||||||
|
if (selections.length === 1) {
|
||||||
|
editor.revealRange(selections[0], vscode.TextEditorRevealType.InCenterIfOutsideViewport);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSnippet(snip: string): [string, [number, number]] | undefined {
|
function parseSnippet(snip: string): [string, [number, number]] | undefined {
|
||||||
|
|
Loading…
Reference in a new issue