Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/debug_refcell.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[unstable]
build-std = ["std"]
build-std-features = ["debug_refcell"]
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"program": "${workspaceFolder}/target/debug/edit",
"cwd": "${workspaceFolder}",
"args": [
"${workspaceFolder}/crates/edit/src/bin/edit/main.rs"
"${workspaceFolder}/assets/highlighting-tests/json.json"
],
},
{
Expand Down
57 changes: 57 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resolver = "2"
edition = "2024"
license = "MIT"
repository = "https://github.com/microsoft/edit"
rust-version = "1.88"
rust-version = "1.92"

# We use `opt-level = "s"` as it significantly reduces binary size.
# We could then use the `#[optimize(speed)]` attribute for spot optimizations.
Expand All @@ -28,5 +28,7 @@ lto = "thin" # Similarly, speed up linking by a ton

[workspace.dependencies]
edit = { path = "./crates/edit" }
lsh = { path = "./crates/lsh" }
lsh-bin = { path = "./crates/lsh-bin" }
stdext = { path = "./crates/stdext" }
unicode-gen = { path = "./crates/unicode-gen" }
62 changes: 62 additions & 0 deletions assets/highlighting-tests/COMMIT_EDITMSG
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
lsh: flip legacy flag, add follow-up hook & diff test

Refactors placeholder logic and introduces a lightweight follow-up hook.
Adds diff highlighting test and removes outdated asset to streamline visuals.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch foobar
# Your branch is up to date with 'origin/foobar'.
#
# Changes to be committed:
# renamed: foo.rs -> bar.rs
# modified: src/lsh/definitions.rs
# deleted: assets/old_logo.svg
# new file: baz.rs
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/src/lsh/definitions.rs b/src/lsh/definitions.rs
index a1b2c3d..d4c3b2a 100644
--- a/src/lsh/definitions.rs
+++ b/src/lsh/definitions.rs
@@ -12,9 +12,11 @@ // context line 12
// context line 13
-// old placeholder logic A
-const LEGACY_FLAG: bool = true;
-// end legacy block
+// updated placeholder logic A
+const LEGACY_FLAG: bool = false; // flipped for test
+// added note: migration in progress
+// end legacy block
// context line 19
// context line 20
@@ -42,7 +44,12 @@ // context line 42
// context line 43
- do_placeholder_action(alpha, beta);
+ // Split actions for clarity
+ do_placeholder_prepare(alpha);
+ do_placeholder_action(alpha, beta);
+ if (enable_extra()) {
+ do_placeholder_followup(beta);
+ }
// context line 50
// context line 51
// context line 52
@@ -90,6 +97,15 @@ // context line 90
// context line 91
// context line 92
+/// Added lightweight fake helper
+fn enable_extra() -> bool {
+ // Pretend this consults a config value
+ true
+}
+
+// Temporary debug instrumentation (to be removed)
+const _DEBUG_HOOK: &str = "lsh:extra";
+
// context line 93
// context line 94
// context line 95
71 changes: 71 additions & 0 deletions assets/highlighting-tests/bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

# This is a comment

readonly VAR1="Hello" # String literal
VAR2=42 # Integer literal
VAR3=$((VAR2 + 8)) # Arithmetic expansion
VAR4=$(echo "World") # Command substitution

function greet() { # Function definition
local name="$1" # Local variable, parameter expansion
echo "${VAR1}, $name! $VAR4" # String, parameter expansion, variable
}

greet "User" # Function call, string literal

if [[ $VAR2 -gt 40 && $VAR3 -eq 50 ]]; then # Conditional, test, operators
echo "Numbers are correct" # String literal
elif (( VAR2 < 40 )); then # Arithmetic test
echo 'VAR2 is less than 40' # Single-quoted string
else
echo "Other case"
fi

for i in {1..3}; do # Brace expansion, for loop
echo "Loop $i" # String, variable
done

case "$VAR4" in # Case statement
World) echo "It's World";; # Pattern, string
*) echo "Unknown";; # Wildcard
esac

arr=(one two three) # Array
echo "${arr[1]}" # Array access

declare -A assoc # Associative array
assoc[key]="value"
echo "${assoc[key]}"

# Here document
cat <<EOF
Multi-line
string with $VAR1
EOF

# Here string
grep H <<< "$VAR1"

# Subshell
(subshell_var=99; echo $subshell_var)

# Redirection
echo "Redirected" > /dev/null

# Background job
sleep 1 &

# Arithmetic assignment
let VAR2+=1

# Process substitution
diff <(echo foo) <(echo bar)

# Command grouping
{ echo "Group 1"; echo "Group 2"; }

# Escaped characters
echo "A quote: \" and a backslash: \\"

# End of file
41 changes: 41 additions & 0 deletions assets/highlighting-tests/batch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@echo off
REM --- String, Variable, Label, Command, Operator, Number, Delimiter, Comment ---

:: Label
:Start

:: Variable assignment and usage
set "VAR1=Hello"
set VAR2=World

:: String with spaces and special characters
set "STR=Batch ^& CMD!"

:: Arithmetic operation (number, operator)
set /a SUM=5+10

:: IF statement (keyword, operator, string, variable)
if "%VAR1%"=="Hello" (
echo %VAR1%, %VAR2%! %STR%
) else (
echo Not matched!
)

:: FOR loop (keyword, variable, delimiter, string)
for %%F in (*.bat) do (
echo Found file: %%F
)

:: CALL command (keyword, label)
call :SubRoutine

:: GOTO command (keyword, label)
goto :End

:: Subroutine with parameter
:SubRoutine
echo In subroutine with SUM=%SUM%
goto :eof

:End
REM End of script
Loading