Color picker goober works w single quotes (#6957)
* lsp stuffs Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -4220,8 +4220,8 @@ sketch001 = startSketchOn(XY)
|
||||
result,
|
||||
vec![tower_lsp::lsp_types::ColorInformation {
|
||||
range: tower_lsp::lsp_types::Range {
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 24 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 33 },
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 25 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 32 },
|
||||
},
|
||||
color: tower_lsp::lsp_types::Color {
|
||||
red: 1.0,
|
||||
@ -4272,8 +4272,8 @@ sketch001 = startSketchOn(XY)
|
||||
result,
|
||||
vec![tower_lsp::lsp_types::ColorInformation {
|
||||
range: tower_lsp::lsp_types::Range {
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 24 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 33 },
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 25 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 32 },
|
||||
},
|
||||
color: tower_lsp::lsp_types::Color {
|
||||
red: 1.0,
|
||||
@ -4291,8 +4291,8 @@ sketch001 = startSketchOn(XY)
|
||||
uri: "file:///test.kcl".try_into().unwrap(),
|
||||
},
|
||||
range: tower_lsp::lsp_types::Range {
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 24 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 33 },
|
||||
start: tower_lsp::lsp_types::Position { line: 4, character: 25 },
|
||||
end: tower_lsp::lsp_types::Position { line: 4, character: 32 },
|
||||
},
|
||||
color: tower_lsp::lsp_types::Color {
|
||||
red: 1.0,
|
||||
|
@ -438,8 +438,15 @@ impl Node<Program> {
|
||||
let add_color = |literal: &Node<Literal>| {
|
||||
// Check if the string is a color.
|
||||
if let Some(c) = literal.value.is_color() {
|
||||
let source_range = literal.as_source_range();
|
||||
// We subtract 1 from either side because of the "'s in the literal.
|
||||
let fixed_source_range = SourceRange::new(
|
||||
source_range.start() + 1,
|
||||
source_range.end() - 1,
|
||||
source_range.module_id(),
|
||||
);
|
||||
let color = ColorInformation {
|
||||
range: literal.as_source_range().to_lsp_range(code),
|
||||
range: fixed_source_range.to_lsp_range(code),
|
||||
color: tower_lsp::lsp_types::Color {
|
||||
red: c.r,
|
||||
green: c.g,
|
||||
@ -498,7 +505,11 @@ impl Node<Program> {
|
||||
crate::walk::walk(self, |node: crate::walk::Node<'a>| {
|
||||
match node {
|
||||
crate::walk::Node::Literal(literal) => {
|
||||
if literal.start == pos_start && literal.end == pos_end && literal.value.is_color().is_some() {
|
||||
// Account for the quotes in the literal.
|
||||
if (literal.start + 1) == pos_start
|
||||
&& (literal.end - 1) == pos_end
|
||||
&& literal.value.is_color().is_some()
|
||||
{
|
||||
found.replace(true);
|
||||
return Ok(true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user