Skip to content

Commit 4b4960a

Browse files
committed
autocomplete
Signed-off-by: Nick Cameron <nrc@ncameron.org>
1 parent 8c36105 commit 4b4960a

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

rust/kcl-lib/src/docs/kcl_doc.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,16 @@ impl ArgData {
816816
}
817817
match self.ty.as_deref() {
818818
Some("Sketch") if self.kind == ArgKind::Special => None,
819-
Some(s) if s.starts_with("number") => Some((index, format!(r#"{label}${{{}:10}}"#, index))),
819+
Some(s) if s.starts_with("number") => {
820+
let value = match &*self.name {
821+
"angleStart" => "0",
822+
"angleEnd" => "180deg",
823+
"angle" => "180deg",
824+
"arcDegrees" => "360deg",
825+
_ => "10",
826+
};
827+
Some((index, format!(r#"{label}${{{}:{value}}}"#, index)))
828+
}
820829
Some("Point2d") => Some((index + 1, format!(r#"{label}[${{{}:0}}, ${{{}:0}}]"#, index, index + 1))),
821830
Some("Point3d") => Some((
822831
index + 2,

rust/kcl-lib/src/docs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod tests {
106106
let snippet = data.to_autocomplete_snippet();
107107
assert_eq!(
108108
snippet,
109-
r#"arc(angleStart = ${0:10}, angleEnd = ${1:10}, diameter = ${2:10})"#
109+
r#"arc(angleStart = ${0:0}, angleEnd = ${1:180deg}, diameter = ${2:10})"#
110110
);
111111
}
112112

@@ -172,7 +172,7 @@ mod tests {
172172
let snippet = helix_fn.to_autocomplete_snippet();
173173
assert_eq!(
174174
snippet,
175-
r#"helix(revolutions = ${0:10}, angleStart = ${1:10}, radius = ${2:10}, axis = ${3:X}, length = ${4:10})"#
175+
r#"helix(revolutions = ${0:10}, angleStart = ${1:0}, radius = ${2:10}, axis = ${3:X}, length = ${4:10})"#
176176
);
177177
}
178178

rust/kcl-lib/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ impl Program {
228228
}
229229

230230
/// Change the meta settings for the kcl file.
231-
pub fn change_default_units(
232-
&self,
233-
length_units: Option<execution::types::UnitLen>,
234-
) -> Result<Self, KclError> {
231+
pub fn change_default_units(&self, length_units: Option<execution::types::UnitLen>) -> Result<Self, KclError> {
235232
Ok(Self {
236233
ast: self.ast.change_default_units(length_units)?,
237234
original_file_contents: self.original_file_contents.clone(),

rust/kcl-lib/src/parsing/ast/types/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,7 @@ impl Node<Program> {
357357
Ok(None)
358358
}
359359

360-
pub fn change_default_units(
361-
&self,
362-
length_units: Option<UnitLen>,
363-
) -> Result<Self, KclError> {
360+
pub fn change_default_units(&self, length_units: Option<UnitLen>) -> Result<Self, KclError> {
364361
let mut new_program = self.clone();
365362
let mut found = false;
366363
for node in &mut new_program.inner_attrs {

0 commit comments

Comments
 (0)