mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
use unicode bar for drawing the cursor
This commit is contained in:
parent
1060041393
commit
cf4720ffd5
4 changed files with 24 additions and 17 deletions
|
@ -16,7 +16,7 @@ use crate::{Assist, AssistCtx, AssistId};
|
||||||
// Adds or changes existing visibility specifier.
|
// Adds or changes existing visibility specifier.
|
||||||
//
|
//
|
||||||
// ```
|
// ```
|
||||||
// fn<|> frobnicate() {}
|
// <|>fn frobnicate() {}
|
||||||
// ```
|
// ```
|
||||||
// ->
|
// ->
|
||||||
// ```
|
// ```
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn doctest_change_visibility() {
|
||||||
check(
|
check(
|
||||||
"change_visibility",
|
"change_visibility",
|
||||||
r#####"
|
r#####"
|
||||||
fn<|> frobnicate() {}
|
<|>fn frobnicate() {}
|
||||||
"#####,
|
"#####,
|
||||||
r#####"
|
r#####"
|
||||||
pub(crate) fn frobnicate() {}
|
pub(crate) fn frobnicate() {}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Assists
|
# Assists
|
||||||
|
|
||||||
|
Cursor position or selection is signified by `┃` character.
|
||||||
|
|
||||||
|
|
||||||
## `add_derive`
|
## `add_derive`
|
||||||
|
|
||||||
Adds a new `#[derive()]` clause to a struct or enum.
|
Adds a new `#[derive()]` clause to a struct or enum.
|
||||||
|
@ -8,7 +11,7 @@ Adds a new `#[derive()]` clause to a struct or enum.
|
||||||
// BEFORE
|
// BEFORE
|
||||||
struct Point {
|
struct Point {
|
||||||
x: u32,
|
x: u32,
|
||||||
y: u32,<|>
|
y: u32,┃
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -26,7 +29,7 @@ Specify type for a let binding.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
let x<|> = 92;
|
let x┃ = 92;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -42,7 +45,7 @@ Adds a new inherent impl for a type.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
struct Ctx<T: Clone> {
|
struct Ctx<T: Clone> {
|
||||||
data: T,<|>
|
data: T,┃
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -69,7 +72,7 @@ trait T {
|
||||||
|
|
||||||
impl T for () {
|
impl T for () {
|
||||||
Type X = ();
|
Type X = ();
|
||||||
fn foo(&self) {}<|>
|
fn foo(&self) {}┃
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +103,7 @@ trait T {
|
||||||
fn bar(&self) {}
|
fn bar(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl T for () {<|>
|
impl T for () {┃
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +131,7 @@ This means something of the form `!x` or `x != y`.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
if x != 4 ||<|> !y {}
|
if x != 4 ||┃ !y {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -143,7 +146,7 @@ Adds or changes existing visibility specifier.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn<|> frobnicate() {}
|
┃fn frobnicate() {}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
pub(crate) fn frobnicate() {}
|
pub(crate) fn frobnicate() {}
|
||||||
|
@ -156,7 +159,7 @@ Replace a large conditional with a guarded return.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
<|>if cond {
|
┃if cond {
|
||||||
foo();
|
foo();
|
||||||
bar();
|
bar();
|
||||||
}
|
}
|
||||||
|
@ -182,7 +185,7 @@ enum Action { Move { distance: u32 }, Stop }
|
||||||
|
|
||||||
fn handle(action: Action) {
|
fn handle(action: Action) {
|
||||||
match action {
|
match action {
|
||||||
<|>
|
┃
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +207,7 @@ Flips operands of a binary expression.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = 90 +<|> 2;
|
let _ = 90 +┃ 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -220,7 +223,7 @@ Flips two comma-separated items.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
((1, 2),<|> (3, 4));
|
((1, 2),┃ (3, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
@ -236,7 +239,7 @@ Inlines local variable.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
let x<|> = 1 + 2;
|
let x┃ = 1 + 2;
|
||||||
x * 4;
|
x * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +256,7 @@ Extracts subexpression into a variable.
|
||||||
```rust
|
```rust
|
||||||
// BEFORE
|
// BEFORE
|
||||||
fn main() {
|
fn main() {
|
||||||
<|>(1 + 2)<|> * 4;
|
┃(1 + 2)┃ * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AFTER
|
// AFTER
|
||||||
|
|
|
@ -107,9 +107,13 @@ r#####"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
|
fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
|
||||||
let mut buf = String::from("# Assists\n");
|
let mut buf = String::from(
|
||||||
|
"# Assists\n\nCursor position or selection is signified by `┃` character.\n\n",
|
||||||
|
);
|
||||||
|
|
||||||
for assist in assists {
|
for assist in assists {
|
||||||
|
let before = assist.before.replace("<|>", "┃"); // Unicode pseudo-graphics bar
|
||||||
|
let after = assist.after.replace("<|>", "┃");
|
||||||
let docs = format!(
|
let docs = format!(
|
||||||
"
|
"
|
||||||
## `{}`
|
## `{}`
|
||||||
|
@ -124,7 +128,7 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> {
|
||||||
{}
|
{}
|
||||||
```
|
```
|
||||||
",
|
",
|
||||||
assist.id, assist.doc, assist.before, assist.after
|
assist.id, assist.doc, before, after
|
||||||
);
|
);
|
||||||
buf.push_str(&docs);
|
buf.push_str(&docs);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue