A simple CPU rendered GUI IDE experience.
morewhat diagnostic
bendn 4 months ago
parent df001ad · commit 4f47a3b
-rw-r--r--diag405
-rw-r--r--src/com.rs4
-rw-r--r--src/hov.rs2
-rw-r--r--src/lsp.rs3
-rw-r--r--src/main.rs39
-rw-r--r--src/text.rs15
6 files changed, 449 insertions, 19 deletions
diff --git a/diag b/diag
new file mode 100644
index 0000000..0c1fbee
--- /dev/null
+++ b/diag
@@ -0,0 +1,405 @@
+[
+ {
+ "range": {
+ "start": {
+ "line": 69,
+ "character": 39
+ },
+ "end": {
+ "line": 69,
+ "character": 44
+ }
+ },
+ "severity": 2,
+ "code": "unused_imports",
+ "source": "rustc",
+ "message": "unused import: `color`\n`#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 69,
+ "character": 37
+ },
+ "end": {
+ "line": 69,
+ "character": 44
+ }
+ }
+ },
+ "message": "remove the unused import"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused import: `color`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:70:40\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m70\u001b[0m \u001b[1m\u001b[94m|\u001b[0m use crate::text::{Diff, TextArea, col, color, is_word};\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 6
+ },
+ "end": {
+ "line": 1272,
+ "character": 7
+ }
+ },
+ "severity": 2,
+ "code": "unused_parens",
+ "source": "rustc",
+ "message": "unnecessary parentheses around type\n`#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 6
+ },
+ "end": {
+ "line": 1272,
+ "character": 7
+ }
+ }
+ },
+ "message": "remove these parentheses"
+ }
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 21
+ },
+ "end": {
+ "line": 1272,
+ "character": 22
+ }
+ },
+ "severity": 2,
+ "code": "unused_parens",
+ "source": "rustc",
+ "message": "unnecessary parentheses around type\n`#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 6
+ },
+ "end": {
+ "line": 1272,
+ "character": 7
+ }
+ }
+ },
+ "message": "remove these parentheses"
+ }
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unnecessary parentheses around type\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(unused_parens)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: remove these parentheses\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m(\u001b[0m(usize, usize)\u001b[91m)\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C((usize, usize) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1282,
+ "character": 10
+ },
+ "end": {
+ "line": 1282,
+ "character": 11
+ }
+ },
+ "severity": 2,
+ "code": "unused_variables",
+ "source": "rustc",
+ "message": "unused variable: `x`",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1282,
+ "character": 10
+ },
+ "end": {
+ "line": 1282,
+ "character": 11
+ }
+ }
+ },
+ "message": "if this is intentional, prefix it with an underscore: `_x`"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1283:11\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1283\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Selection(x) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 8
+ },
+ "end": {
+ "line": 1310,
+ "character": 9
+ }
+ },
+ "severity": 2,
+ "code": "unused_variables",
+ "source": "rustc",
+ "message": "unused variable: `x`",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 8
+ },
+ "end": {
+ "line": 1310,
+ "character": 9
+ }
+ }
+ },
+ "message": "if this is intentional, prefix it with an underscore: `_x`"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `x`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:9\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m \u001b[1m\u001b[33mhelp: if this is intentional, prefix it with an underscore: `_x`\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 11
+ },
+ "end": {
+ "line": 1310,
+ "character": 12
+ }
+ },
+ "severity": 2,
+ "code": "unused_variables",
+ "source": "rustc",
+ "message": "unused variable: `y`",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 11
+ },
+ "end": {
+ "line": 1310,
+ "character": 12
+ }
+ }
+ },
+ "message": "you might have meant to pattern match on the similarly named constant `N`: `com::N`"
+ },
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 11
+ },
+ "end": {
+ "line": 1310,
+ "character": 12
+ }
+ }
+ },
+ "message": "if this is intentional, prefix it with an underscore: `_y`"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `y`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:12\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[91m- \u001b[0mSearch((x, \u001b[91my\u001b[0m, m)) => {\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[92m+ \u001b[0mSearch((x, \u001b[92mcom::N\u001b[0m, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, \u001b[92m_\u001b[0my, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 14
+ },
+ "end": {
+ "line": 1310,
+ "character": 15
+ }
+ },
+ "severity": 2,
+ "code": "unused_variables",
+ "source": "rustc",
+ "message": "unused variable: `m`",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 14
+ },
+ "end": {
+ "line": 1310,
+ "character": 15
+ }
+ }
+ },
+ "message": "you might have meant to pattern match on the similarly named constant `N`: `com::N`"
+ },
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1310,
+ "character": 14
+ },
+ "end": {
+ "line": 1310,
+ "character": 15
+ }
+ }
+ },
+ "message": "if this is intentional, prefix it with an underscore: `_m`"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: unused variable: `m`\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1311:15\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m|\u001b[0m Search((x, y, m)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: you might have meant to pattern match on the similarly named constant `N`\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[91m- \u001b[0mSearch((x, y, \u001b[91mm\u001b[0m)) => {\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[92m+ \u001b[0mSearch((x, y, \u001b[92mcom::N\u001b[0m)) => {\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[96mhelp\u001b[0m: if this is intentional, prefix it with an underscore\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1311\u001b[0m \u001b[1m\u001b[94m| \u001b[0mSearch((x, y, \u001b[92m_\u001b[0mm)) => {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[92m+\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 6
+ },
+ "end": {
+ "line": 1272,
+ "character": 22
+ }
+ },
+ "severity": 2,
+ "code": "dead_code",
+ "source": "rustc",
+ "message": "field `0` is never read\n`Action` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n`#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default",
+ "relatedInformation": [
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1312,
+ "character": 4
+ },
+ "end": {
+ "line": 1312,
+ "character": 5
+ }
+ }
+ },
+ "message": "field in this variant"
+ },
+ {
+ "location": {
+ "uri": "file:///home/os/gracilaria/src/main.rs",
+ "range": {
+ "start": {
+ "line": 1272,
+ "character": 6
+ },
+ "end": {
+ "line": 1272,
+ "character": 22
+ }
+ }
+ },
+ "message": "consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field: `()`"
+ }
+ ],
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: field `0` is never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1273:7\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(((usize, usize)) => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^^^^^\u001b[0m\n\u001b[1m\u001b[94m...\u001b[0m\n\u001b[1m\u001b[94m1313\u001b[0m \u001b[1m\u001b[94m|\u001b[0m C(_) => Search((x, y, m)),\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m-\u001b[0m \u001b[1m\u001b[94mfield in this variant\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Action` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default\n\u001b[1m\u001b[96mhelp\u001b[0m: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[91m- \u001b[0m C(\u001b[91m((usize, usize))\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n\u001b[1m\u001b[94m1273\u001b[0m \u001b[92m+ \u001b[0m C(\u001b[92m()\u001b[0m => .. if unsafe { CLICKING }) => Selection(0..0) [StartSelection],\n \u001b[1m\u001b[94m|\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1422,
+ "character": 3
+ },
+ "end": {
+ "line": 1422,
+ "character": 15
+ }
+ },
+ "severity": 2,
+ "code": "dead_code",
+ "source": "rustc",
+ "message": "function `frunctinator` is never used",
+ "tags": [
+ 1
+ ],
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: function `frunctinator` is never used\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1423:4\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1423\u001b[0m \u001b[1m\u001b[94m|\u001b[0m fn frunctinator(\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^\u001b[0m\n\n"
+ }
+ },
+ {
+ "range": {
+ "start": {
+ "line": 1427,
+ "character": 31
+ },
+ "end": {
+ "line": 1427,
+ "character": 41
+ }
+ },
+ "severity": 2,
+ "code": "path_statements",
+ "source": "rustc",
+ "message": "path statement with no effect\n`#[warn(path_statements)]` (part of `#[warn(unused)]`) on by default",
+ "data": {
+ "rendered": "\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: path statement with no effect\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:1428:32\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m1428\u001b[0m \u001b[1m\u001b[94m|\u001b[0m lower::saturating::math! { parameter1 };\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(path_statements)]` (part of `#[warn(unused)]`) on by default\n\n"
+ }
+ }
+] \ No newline at end of file
diff --git a/src/com.rs b/src/com.rs
index 3af3be3..e5e80f6 100644
--- a/src/com.rs
+++ b/src/com.rs
@@ -9,7 +9,7 @@ use itertools::Itertools;
use lsp_types::*;
use crate::FG;
-use crate::text::{color, color_, set_a};
+use crate::text::{col, color, color_, set_a};
#[derive(Debug)]
pub struct Complete {
@@ -174,7 +174,7 @@ fn r(
indices: &[u32],
to: &mut Vec<Cell>,
) {
- let bg = if selected { color(b"#262d3b") } else { color(b"#1c212b") };
+ let bg = if selected { col!("#262d3b") } else { col!("#1c212b") };
let ds: Style = Style { bg: bg, color: FG, flags: 0 };
let d: Cell = Cell { letter: None, style: ds };
diff --git a/src/hov.rs b/src/hov.rs
index 6e467da..e8421db 100644
--- a/src/hov.rs
+++ b/src/hov.rs
@@ -261,7 +261,7 @@ pub fn markdown2(c: usize, x: &Node) -> Vec<Cell> {
}
r.to
}
-pub const BG: [u8; 3] = text::color(b"#191E27");
+pub const BG: [u8; 3] = text::col!("#191E27");
#[test]
fn t() {
use std::time::Instant;
diff --git a/src/lsp.rs b/src/lsp.rs
index 5ee1f26..23177de 100644
--- a/src/lsp.rs
+++ b/src/lsp.rs
@@ -290,8 +290,7 @@ impl Client {
},
Err(e) => return Err(e.into()),
};
- log::info!("{x:?}");
- match x {
+ match x.clone() {
DocumentDiagnosticReportResult::Report(
DocumentDiagnosticReport::Full(
RelatedFullDocumentDiagnosticReport {
diff --git a/src/main.rs b/src/main.rs
index dab2dc4..f39ab27 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,7 @@
// this looks pretty good though
#![feature(tuple_trait, unboxed_closures, fn_traits)]
#![feature(
+ slice_as_array,
str_as_str,
lazy_type_alias,
const_convert,
@@ -66,7 +67,7 @@ use winit::window::Icon;
use crate::bar::Bar;
use crate::hov::Hovr;
use crate::lsp::{RedrawAfter, RqS};
-use crate::text::{Diff, TextArea, color, is_word};
+use crate::text::{Diff, TextArea, col, color, is_word};
mod bar;
pub mod com;
pub mod hov;
@@ -449,19 +450,38 @@ pub(crate) fn entry(event_loop: EventLoop<()>) {
|(_c, _r), text, mut x| {
if let Some((lsp, p)) = lsp!() && let Some(diag) = lsp.diagnostics.get(&Url::from_file_path(p).unwrap(), &lsp.diagnostics.guard()) {
for diag in diag {
+ let sev = diag.severity.unwrap_or(DiagnosticSeverity::ERROR);
let f = |cell:&mut Cell| {
- let sev = diag.severity.unwrap_or(DiagnosticSeverity::ERROR);
cell.style.bg.blend(match sev {
- DiagnosticSeverity::ERROR => color(b"#ff66662c"),
- DiagnosticSeverity::WARNING => color(b"#9469242c"),
+ DiagnosticSeverity::ERROR => col!("#ff66662c"),
+ DiagnosticSeverity::WARNING => col!("#9469242c"),
_ => return
});
};
if diag.range.start == diag.range.end {
x.get((diag.range.start.character as _, diag.range.start.line as _)).map(f);
} else {
- x.get_range((diag.range.start.character as _, diag.range.start.line as _), (diag.range.end.character as usize, diag.range.end.line as _))
- .for_each(f)
+ x.get_range((diag.range.start.character as _, diag.range.start.line as _), (diag.range.end.character as usize, diag.range.end.line as _))
+ .for_each(f)
+ }
+ {
+ let l = diag.range.start.line as usize;
+ let x_ = text.rope.line(l).len_chars() + 2;
+ x.get_range(
+ (x_, l),
+ (x_ + diag.message.chars().count(), l),
+ ).zip(diag.message.chars()).for_each(|(x, c)| {
+ *x=match sev {
+ DiagnosticSeverity::WARNING => { Style{ bg :col!("#362f2f"),
+ color: col!("#fa973a"), flags: 0 }},
+ DiagnosticSeverity::ERROR => {
+ Style { bg : col!("#342833"),
+ color : col!("#f26462"), flags: 0 }
+ },
+ _ => return
+ }.basic(c)
+
+ });
}
}
}
@@ -1031,16 +1051,16 @@ hovering.request = (DropH::new(handle), hover).into();
}
Some(Do::Insert(x, c)) => {
hist.push_if_changed(&text);
- text.rope.remove(x.clone());
+ _ = text.remove(x.clone());
text.cursor = x.start;
text.setc();
- text.insert_(c);
+ text.insert(&c);
hist.push_if_changed(&text);
}
Some(Do::Delete(x)) => {
hist.push_if_changed(&text);
text.cursor = x.start;
- text.rope.remove(x);
+ _ = text.remove(x);
hist.push_if_changed(&text);
}
Some(Do::Copy(x)) => {
@@ -1382,6 +1402,7 @@ rust_fsm::state_machine! {
Complete(_x) => K(_) => _ [Request(CompletionContext { trigger_kind: CompletionTriggerKind::TRIGGER_FOR_INCOMPLETE_COMPLETIONS, trigger_character:None })],
}
+
use com::Complete;
impl Default for CompletionState {
fn default() -> Self {
diff --git a/src/text.rs b/src/text.rs
index 7e2e2ec..f37b0b9 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -169,6 +169,12 @@ where
car::map!(parse, |[a, b]| a * 16 + b)
}
+macro_rules! col {
+ ($x:literal) => {{
+ const __N: usize = $x.len();
+ const { crate::text::color($x.as_bytes().as_array::<__N>().unwrap()) }
+ }};
+}
#[derive(Clone, Debug)]
pub struct Diff {
pub changes: (Patches<u8>, Patches<u8>),
@@ -302,9 +308,6 @@ impl TextArea {
.and_then(|l| Some(self.rope.try_line_to_char(l).ok()? + x))
}
- pub fn insert_(&mut self, c: SmolStr) {
- self.insert(&c);
- }
pub fn remove(&mut self, r: Range<usize>) -> Result<(), ropey::Error> {
self.rope.try_remove(r.clone())?;
self.tabstops.as_mut().map(|x| {
@@ -445,7 +448,7 @@ impl TextArea {
if x < self.ho + 4 {
self.ho = x.saturating_sub(4);
} else if x + 4 > (self.ho + self.c) {
- self.ho = (x - self.c) + 4;
+ self.ho = (x.saturating_sub(self.c)) + 4;
}
}
@@ -787,7 +790,7 @@ impl TextArea {
(self.ho + c, self.y(self.cursor)),
)
.for_each(|x| {
- x.style.bg = color(b"#1a1f29");
+ x.style.bg = const { color(b"#1a1f29") };
});
// let tokens = None::<(
@@ -1483,3 +1486,5 @@ impl<I: Iterator<Item = T>, T> CoerceOption<T> for Option<I> {
self.into_iter().flatten()
}
}
+// #[test]
+pub(crate) use col;