diff --git a/CHANGELOG.md b/CHANGELOG.md index 86a6d69191..9e67c36bcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ nodes should be treated as atoms. This ensures comments are treated more consistently across languages. This fixes cases in Elm where comment differences were ignored, and may improve other languages too. +### Display + +Inline display now includes unchanged lines between hunks. + ## 0.58 (released 11th May 2024) ### Parsing diff --git a/src/display/inline.rs b/src/display/inline.rs index 8ad82ffe27..96538b10f7 100644 --- a/src/display/inline.rs +++ b/src/display/inline.rs @@ -1,5 +1,7 @@ //! Inline, or "unified" diff display. +use line_numbers::LineNumber; + use crate::{ constants::Side, display::context::{calculate_after_context, calculate_before_context, opposite_positions}, @@ -91,28 +93,66 @@ pub(crate) fn print( display_options.num_context_lines as usize, ); - for (lhs_line, _) in before_lines { - if let Some(lhs_line) = lhs_line { - print!( - "{} {}", - apply_line_number_color( - &format_line_num(lhs_line), - false, - Side::Left, - display_options, - ), - lhs_colored_lines[lhs_line.as_usize()] - ); + // Common context lines will be emitted once at first or last. Uncommon + // lines will be inserted in between. Missing lines towards the hunk + // will also be filled. + let first_rhs_line = { + let common_len = before_lines + .iter() + .take_while(|(lhs_line, rhs_line)| lhs_line.is_some() && rhs_line.is_some()) + .count(); + let (common_lines, uncommon_lines) = before_lines.split_at(common_len); + if let Some((_, rhs_line)) = uncommon_lines.first() { + *rhs_line // first uncommon + } else if let Some(&(_, Some(LineNumber(a)))) = common_lines.last() { + match to_rhs_iter(hunk_lines).next() { + Some(LineNumber(b)) => (a..=b).map(LineNumber).nth(1), // next of common + None => None, + } + } else { + None } - } + }; + let last_lhs_line = { + let common_len = after_lines + .iter() + .rev() + .take_while(|(lhs_line, rhs_line)| lhs_line.is_some() && rhs_line.is_some()) + .count(); + let (uncommon_lines, common_lines) = + after_lines.split_at(after_lines.len() - common_len); + if let Some((lhs_line, _)) = uncommon_lines.last() { + *lhs_line // last uncommon + } else if let Some(&(Some(LineNumber(b)), _)) = common_lines.first() { + match to_lhs_iter(hunk_lines).next_back() { + Some(LineNumber(a)) => (a..=b).map(LineNumber).nth_back(1), // prev of common + None => None, + } + } else { + None + } + }; + + let all_lhs_lines = itertools::chain!( + to_lhs_iter(&before_lines), + to_lhs_iter(hunk_lines), + last_lhs_line, + ); + let all_rhs_lines = itertools::chain!( + first_rhs_line, + to_rhs_iter(hunk_lines), + to_rhs_iter(&after_lines), + ); - for (lhs_line, _) in hunk_lines { - if let Some(lhs_line) = lhs_line { + if let Some((first, last)) = get_first_last(all_lhs_lines) { + let mut lhs_hunk_lines = to_lhs_iter(hunk_lines).fuse().peekable(); + for lhs_line in (first.0..=last.0).map(LineNumber) { + let is_novel = lhs_hunk_lines.next_if_eq(&lhs_line).is_some(); print!( "{} {}", apply_line_number_color( - &format_line_num(*lhs_line), - true, + &format_line_num(lhs_line), + is_novel, Side::Left, display_options, ), @@ -120,28 +160,16 @@ pub(crate) fn print( ); } } - for (_, rhs_line) in hunk_lines { - if let Some(rhs_line) = rhs_line { - print!( - " {}{}", - apply_line_number_color( - &format_line_num(*rhs_line), - true, - Side::Right, - display_options, - ), - rhs_colored_lines[rhs_line.as_usize()] - ); - } - } - for (_, rhs_line) in &after_lines { - if let Some(rhs_line) = rhs_line { + if let Some((first, last)) = get_first_last(all_rhs_lines) { + let mut rhs_hunk_lines = to_rhs_iter(hunk_lines).fuse().peekable(); + for rhs_line in (first.0..=last.0).map(LineNumber) { + let is_novel = rhs_hunk_lines.next_if_eq(&rhs_line).is_some(); print!( " {}{}", apply_line_number_color( - &format_line_num(*rhs_line), - false, + &format_line_num(rhs_line), + is_novel, Side::Right, display_options, ), @@ -149,6 +177,25 @@ pub(crate) fn print( ); } } + println!(); } } + +fn to_lhs_iter( + items: &[(Option, Option)], +) -> impl DoubleEndedIterator + '_ { + items.iter().filter_map(|(lhs, _)| *lhs) +} + +fn to_rhs_iter( + items: &[(Option, Option)], +) -> impl DoubleEndedIterator + '_ { + items.iter().filter_map(|(_, rhs)| *rhs) +} + +fn get_first_last(mut iter: impl DoubleEndedIterator) -> Option<(T, T)> { + let first = iter.next()?; + let last = iter.next_back().unwrap_or(first); + Some((first, last)) +} diff --git a/tests/snapshots/cli__samples_inline@Session_1.kt.snap b/tests/snapshots/cli__samples_inline@Session_1.kt.snap index 084f2ba25d..ba7963912f 100644 --- a/tests/snapshots/cli__samples_inline@Session_1.kt.snap +++ b/tests/snapshots/cli__samples_inline@Session_1.kt.snap @@ -9,7 +9,9 @@ input_file: sample_files/Session_1.kt 97   * The session's photo URL. 98   */ 99  val photoUrl: String?, +100  99  val photoUrl: String, + 100  101  /** 102  * IDs of the sessions related to this session. 103  */ @@ -18,9 +20,21 @@ input_file: sample_files/Session_1.kt 113  // available. 114  return startTime <= now && endTime >= now 115  } +116  +117  /** +118   * Returns whether the session has a video or not. A session could be live streaming or have a +119   * recorded session. Both live stream and recorded videos are stored in [Session.youTubeUrl]. +120   */ 121  fun hasVideo() = youTubeUrl.isNotEmpty() + 116  117  val hasPhoto inline get() = photoUrl.isNotEmpty() + 118  + 119  /** + 120  * Returns whether the session has a video or not. A session could be live streaming or have a + 121  * recorded session. Both live stream and recorded videos are stored in [Session.youTubeUrl]. + 122  */ 123  val hasVideo inline get() = youTubeUrl.isNotEmpty() + 124  125  val hasPhotoOrVideo inline get() = hasPhoto || hasVideo 126  127  /** diff --git a/tests/snapshots/cli__samples_inline@ada_1.adb.snap b/tests/snapshots/cli__samples_inline@ada_1.adb.snap index 7e81d6b6f7..e6eb987df9 100644 --- a/tests/snapshots/cli__samples_inline@ada_1.adb.snap +++ b/tests/snapshots/cli__samples_inline@ada_1.adb.snap @@ -6,6 +6,9 @@ input_file: sample_files/ada_1.adb sample_files/ada_2.adb --- Ada 1  with Ada.Text_IO; use Ada.Text_IO; procedure Hello is begin Put_Line ("Hello WORLD!"); end Hello; 1 with Ada.Text_IO; + 2  + 3 procedure Hello is 4  package TIO renames Ada.Text_IO; + 5 begin 6  TIO.Put_Line ("Hello World!"); 7 end Hello; diff --git a/tests/snapshots/cli__samples_inline@bad_combine_1.rs.snap b/tests/snapshots/cli__samples_inline@bad_combine_1.rs.snap index 5e87db6a84..a184a8539d 100644 --- a/tests/snapshots/cli__samples_inline@bad_combine_1.rs.snap +++ b/tests/snapshots/cli__samples_inline@bad_combine_1.rs.snap @@ -13,6 +13,11 @@ input_file: sample_files/bad_combine_1.rs 7  max_rhs_src_line: LineNumber, 8  ) { 9  } +10  +11  fn display_line_nums( +12  ) -> (String, String) { +13  let display_rhs_line_num: String = match rhs_line_num { +14  Some(line_num) => { 15  let s = format_line_num_padded(line_num, rhs_column_width); 5  let s = format_line_num_padded(line_num, widths.rhs_line_nums); 6  if rhs_lines_with_novel.contains(&line_num) { diff --git a/tests/snapshots/cli__samples_inline@clojure_1.clj.snap b/tests/snapshots/cli__samples_inline@clojure_1.clj.snap index 89ad7584b0..cea1dc39a7 100644 --- a/tests/snapshots/cli__samples_inline@clojure_1.clj.snap +++ b/tests/snapshots/cli__samples_inline@clojure_1.clj.snap @@ -12,4 +12,5 @@ input_file: sample_files/clojure_1.clj 7  {:more (inc x) 8  :less (dec x)}) 6  (-> {:more (inc x) + 7  :less (dec x)} 8  (assoc :twice (+ x x)))) diff --git a/tests/snapshots/cli__samples_inline@comma_1.js.snap b/tests/snapshots/cli__samples_inline@comma_1.js.snap index e5f700be85..5a6fc53be9 100644 --- a/tests/snapshots/cli__samples_inline@comma_1.js.snap +++ b/tests/snapshots/cli__samples_inline@comma_1.js.snap @@ -11,12 +11,14 @@ input_file: sample_files/comma_1.js 13  function arrayIncludesWith(array, value, comparator) { 14  let index = -1 15  const length = array == null ? 0 : array.length +16  17  while (++index < length) { 18  if (comparator(value, array[index])) { 13 function arrayIncludesWith(array, target, comparator) { 14  if (array == null) { 15  return false 16  } + 17  18  for (const value of array) { 19  if (comparator(target, value)) { 20  return true diff --git a/tests/snapshots/cli__samples_inline@comments_1.rs.snap b/tests/snapshots/cli__samples_inline@comments_1.rs.snap index c5c6abccce..dc4ebd7947 100644 --- a/tests/snapshots/cli__samples_inline@comments_1.rs.snap +++ b/tests/snapshots/cli__samples_inline@comments_1.rs.snap @@ -8,19 +8,41 @@ input_file: sample_files/comments_1.rs 2  f1(); 3  4  // Changing a single word. +5  f2(); +6  7  // A completely different sentence. +8  f3(); +9  10  if true { +11  /* A multiline comment +12   * whose indentation changes. +13   */ 14  } +15  16  // An example environment variable: FOO="a-b" +17  18  // A single line comment. +19  20  /** A doc comment. 21   * 22   * This line will change. 23   */ 4 // Changing a single word here. + 5 f2(); + 6  7 // A single comment about something. + 8 f3(); + 9  + 10 /* A multiline comment + 11  * whose indentation changes. + 12  */ + 13  14 // An example environment variable: FOO="x-y" + 15  16 // A single line comment. It has become + 17 // a big block comment. Lorem ipsum dolor sit amet, + 18 // consectetur adipiscing elit + 19  20 /** A doc comment. 21  * 22  * This line has changed. diff --git a/tests/snapshots/cli__samples_inline@context_1.rs.snap b/tests/snapshots/cli__samples_inline@context_1.rs.snap index 9b14e2c249..7f7f5adae6 100644 --- a/tests/snapshots/cli__samples_inline@context_1.rs.snap +++ b/tests/snapshots/cli__samples_inline@context_1.rs.snap @@ -9,6 +9,7 @@ input_file: sample_files/context_1.rs 3  if print_unchanged { 4  } 5  } +6  2  match () { 3  x => { 4  let opposite_to_lhs = opposite_positions(&summary.lhs_positions); diff --git a/tests/snapshots/cli__samples_inline@contiguous_1.js.snap b/tests/snapshots/cli__samples_inline@contiguous_1.js.snap index 6f40e4fa8c..ed7786d7a6 100644 --- a/tests/snapshots/cli__samples_inline@contiguous_1.js.snap +++ b/tests/snapshots/cli__samples_inline@contiguous_1.js.snap @@ -6,6 +6,8 @@ input_file: sample_files/contiguous_1.js sample_files/contiguous_2.js --- JavaScript 1 // There are multiple possible diffs here, but we want to prefer 2 // showing A and B on the same line. + 3 var x = [ + 4  "A", "B", 5  "A", "B", 6  "C", "D", 7 ]; diff --git a/tests/snapshots/cli__samples_inline@css_1.css.snap b/tests/snapshots/cli__samples_inline@css_1.css.snap index bb25f585e3..29d4515b00 100644 --- a/tests/snapshots/cli__samples_inline@css_1.css.snap +++ b/tests/snapshots/cli__samples_inline@css_1.css.snap @@ -8,19 +8,37 @@ input_file: sample_files/css_1.css 2  world */ 3  .foo1 { 4  margin: 0 0 20px 0; +5  } +6  7  .bar { 8  margin: 0; +9  } +10  +11  .baz { 12  color: yellow; 13  font-family: "Before"; +14  } +15  +16  .another { 17  margin-left: 0.5em; 3 .bar { 4  margin: 0; + 5 } + 6  7 .foo1 { 8  margin: 0 0 20px 0; 9  color: green; + 10 } + 11  + 12 .baz { 13  color: blue; 14  font-family: "After"; + 15 } + 16  + 17 .another { 18  margin-left: 1em; + 19 } + 20  21 p { 22  color: #000; 23 } diff --git a/tests/snapshots/cli__samples_inline@dart_1.dart.snap b/tests/snapshots/cli__samples_inline@dart_1.dart.snap index a872821e11..129db5c8f4 100644 --- a/tests/snapshots/cli__samples_inline@dart_1.dart.snap +++ b/tests/snapshots/cli__samples_inline@dart_1.dart.snap @@ -8,7 +8,9 @@ input_file: sample_files/dart_1.dart 2  if (x) { 3  Object().a().b(); 4  } +5  6  expect(a.b(c.d()).x); 2  Object()..a()..b(); + 3  4  expect(a.b.c.d()!.x); 5 } diff --git a/tests/snapshots/cli__samples_inline@devicetree_1.dts.snap b/tests/snapshots/cli__samples_inline@devicetree_1.dts.snap index 2582d2acb1..f0e4b4894e 100644 --- a/tests/snapshots/cli__samples_inline@devicetree_1.dts.snap +++ b/tests/snapshots/cli__samples_inline@devicetree_1.dts.snap @@ -31,19 +31,53 @@ input_file: sample_files/devicetree_1.dts 34  i-cache-size = <65536>; 35  d-cache-size = <32768>; 36  }; +37  +38  }; +39  +40  randomnode { +41  string = "\xff\0stuffstuff\t\t\t\n\n\n"; +42  blob = [0a 0b 0c 0d de ea ad be ef]; +43  ref = < &{/memory@0} >; +44  mixed = "abc", [1234], <0xa 0xb 0xc>; 45  old = <12345>; 46  }; +47  +48  memory@0 { +49  device_type = "memory"; +50  memreg: reg = <0x00000000 0x00000000 0x00000000 0x20000000>; +51  }; +52  +53  chosen { 54  bootargs = "root=/dev/sda2"; +55  linux,platform = <0x600>; 29  randomparentnode { + 30  randomnode { + 31  string = "\xff\0stuffstuff\t\t\t\n\n\n"; + 32  blob = [0a 0b 0c 0d de ea ad be ef]; + 33  ref = < &{/memory@0} >; + 34  mixed = "abc", + 35  [1234], + 36  <0xa 0xb 0xc>; 37  new = <12345>; 38  }; 39  }; + 40  + 41  memory@0 { + 42  device_type = "memory"; + 43  memreg: reg = < + 44  0x00000000 0x00000000 + 45  0x00000000 0x20000000>; + 46  }; + 47  48  memory@100000 { 49  device_type = "memory"; 50  memreg: reg = < 51  0x00100000 0x00000000 52  0x00100000 0x20000000>; 53  }; + 54  + 55  chosen { + 56  linux,platform = <0x600>; 57  bootargs = "root=/dev/sda2"; 58  }; 59  diff --git a/tests/snapshots/cli__samples_inline@elisp_contiguous_1.el.snap b/tests/snapshots/cli__samples_inline@elisp_contiguous_1.el.snap index d43a41b3ef..686fe0ff69 100644 --- a/tests/snapshots/cli__samples_inline@elisp_contiguous_1.el.snap +++ b/tests/snapshots/cli__samples_inline@elisp_contiguous_1.el.snap @@ -5,8 +5,14 @@ input_file: sample_files/elisp_contiguous_1.el --- sample_files/elisp_contiguous_2.el --- Emacs Lisp 1  A B +2  C D +3  +4  X Y 5  X Novel 2 A B + 3 C D + 4  + 5 X Y 6 X Z 7  8 End diff --git a/tests/snapshots/cli__samples_inline@elm_1.elm.snap b/tests/snapshots/cli__samples_inline@elm_1.elm.snap index 18e2f1f528..db236d38d2 100644 --- a/tests/snapshots/cli__samples_inline@elm_1.elm.snap +++ b/tests/snapshots/cli__samples_inline@elm_1.elm.snap @@ -5,32 +5,94 @@ input_file: sample_files/elm_1.elm --- sample_files/elm_2.elm --- Elm 1  module Main exposing (blue, green, list, x, y, z) +2  +3  4  {- bar 5   -} +6  list : List Int +7  list = +8  [ 1, 2, 3 ] +9  +10  +11  blue : a -> String +12  blue = 13  always "blue" +14  +15  16  green : a -> String +17  green = 18  always "blue" +19  +20  21  y : Int +22  +23  +24  x = +25  (*) 2 4 +26  +27  +28  y : Int +29  y = 30  (*) 2 4 +31  +32  33  z : String 34  z = 35  "abc" +36  +37  +38  fn : () -> Int -> List String -> String 39  fn _ n strings = 40  let 41  foo : List String -> String 42  foo = +43  String.join (String.fromInt n) 44  in 45  foo strings 1 module Main exposing + 2  ( blue + 3  , list + 4  , x + 5  , y + 6  ) + 7  + 8  9 {- foo 10  -} + 11 list : List Int + 12 list = + 13  [ 1 + 14  , 2 + 15  , 3 16  , 4 + 17  ] + 18  + 19  + 20 blue : a -> String + 21 blue = 22  \_ -> "blue" + 23  + 24  25 green : String + 26 green = 27  "yellow" ++ "blue" + 28  + 29  30 x : Int + 31 x = 32  (*) 2 <| 4 + 33  + 34  + 35 y : Int + 36 y = 37  4 |> (*) 2 + 38  + 39  + 40 fn : + 41  () + 42  -> Int + 43  -> List String 44  -> () + 45  -> String 46 fn () n strings () = 47  String.join (String.fromInt n) strings diff --git a/tests/snapshots/cli__samples_inline@elvish_1.elv.snap b/tests/snapshots/cli__samples_inline@elvish_1.elv.snap index 5187cdcc65..3c87757eac 100644 --- a/tests/snapshots/cli__samples_inline@elvish_1.elv.snap +++ b/tests/snapshots/cli__samples_inline@elvish_1.elv.snap @@ -9,10 +9,16 @@ input_file: sample_files/elvish_1.elv 4  from-json | all (one) | 5  each {|x| echo (exact-num $x[number]): $x[title] } | 6  head -n 7 +7  8  if $true { echo good } else { echo bad } +9  +10  for x [lorem ipsum] { 11  echo $x.pdf 6  head -n 5 + 7  8 if $false { echo good } else { echo bad } + 9  + 10 for x [lorem ipsum] { 11  echo $x.rs 12 } 13  diff --git a/tests/snapshots/cli__samples_inline@hack_1.php.snap b/tests/snapshots/cli__samples_inline@hack_1.php.snap index f98e0d5d62..4b8f97eda5 100644 --- a/tests/snapshots/cli__samples_inline@hack_1.php.snap +++ b/tests/snapshots/cli__samples_inline@hack_1.php.snap @@ -9,7 +9,9 @@ input_file: sample_files/hack_1.php 4   * Do stuff 5   */ 6  function foo(): vec { +7  $x = "foo"; 8  return vec[1]; 6 function foo(): vec<?int> { + 7  $x = "foo"; 8  return vec[1, null]; 9 } diff --git a/tests/snapshots/cli__samples_inline@haskell_1.hs.snap b/tests/snapshots/cli__samples_inline@haskell_1.hs.snap index 9173142eea..aa60267384 100644 --- a/tests/snapshots/cli__samples_inline@haskell_1.hs.snap +++ b/tests/snapshots/cli__samples_inline@haskell_1.hs.snap @@ -5,9 +5,16 @@ input_file: sample_files/haskell_1.hs --- sample_files/haskell_2.hs --- Haskell 2  foo x = x + 1 +3  +4  bar _ = 'c' +5  6  -- | Hello world 1 import System.Process + 2  3 foo x y = x + 1 + W.peek y + 4  + 5 bar _ = 'c' + 6  7 -- | Goodbye world 8 isOne 1 = True 9 isOne _ = False diff --git a/tests/snapshots/cli__samples_inline@hcl_1.hcl.snap b/tests/snapshots/cli__samples_inline@hcl_1.hcl.snap index 5d4b396579..a7574f4700 100644 --- a/tests/snapshots/cli__samples_inline@hcl_1.hcl.snap +++ b/tests/snapshots/cli__samples_inline@hcl_1.hcl.snap @@ -9,10 +9,24 @@ input_file: sample_files/hcl_1.hcl 11  num1 = 2 12  num2 = 2.112 13  num3 = 2.112e-12 +14  num4 = 2.112e+12 +15  num5 = 2.112E+12 +16  num6 = 2.112E-12 +17  num7 = 0x21FF +18  } +19  +20  resource "example" "comments" { 21  // comment 22  # comment 13  num3 = "Hello, World" + 14  num4 = 2.112e+12 + 15  num5 = 2.112E+12 + 16  num6 = 2.112E-12 + 17  num7 = 0x21FF 18  strx = "Hello, Hcl" + 19 } + 20  + 21 resource "example" "comments" { 22  // comment, World! 23  /* 24  comment @@ -26,12 +40,22 @@ input_file: sample_files/hcl_1.hcl 36  for3 = { for k, v in x: k => v } 37  for4 = [ for v in x : v ] 38  for5 = { for v in x : v => v } +39  for6 = [ for v in x : v if v < 3 ] +40  } +41  +42  resource "example" "function_expressions" { +43  func1 = is_number("123") 44  func2 = multiline( 45  arg1, 46  arg2, 47  arg3... 48  ) 37  for5 = { for v in y : v => v + 1 } + 38  for6 = [ for v in x : v if v < 3 ] + 39 } + 40  + 41 resource "example" "function_expressions" { + 42  func1 = is_number("123") 43  func3 = withobject({ 44  "foo" : 2, 45  "bar" : baz, @@ -64,6 +88,7 @@ input_file: sample_files/hcl_1.hcl 77  %{~if a~} "true" %{~else~} "false" %{~endif~} 78  %{ endfor ~} 79  EOF + 80  81  tpl7 = <<-EOF 82  %{ for a in f(b) ~} 83  "true" diff --git a/tests/snapshots/cli__samples_inline@hello_world_1.smali.snap b/tests/snapshots/cli__samples_inline@hello_world_1.smali.snap index c219b8a752..7894514d0c 100644 --- a/tests/snapshots/cli__samples_inline@hello_world_1.smali.snap +++ b/tests/snapshots/cli__samples_inline@hello_world_1.smali.snap @@ -5,7 +5,9 @@ input_file: sample_files/hello_world_1.smali --- sample_files/hello_world_2.smali --- 1/2 --- Smali 1  .class public LHelloWorld; +2  1 .class public LHelloPerson; + 2  3 #Ye olde hello world application 4 #To assemble and run this on a phone or emulator: 5 # @@ -16,11 +18,22 @@ input_file: sample_files/hello_world_1.smali 16  17  .method public static main([Ljava/lang/String;)V 18  .registers 2 +19  +20  sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; +21  22  const-string v1, "Hello World!" +23  24  invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V +25  18  .registers 3 + 19  + 20  sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; + 21  22  const-string v1, "Hello %s!" + 23  24  const-string v2, "Evan" + 25  26  invoke-virtual {v0, v1, v2}, Ljava/io/PrintStream;->printf(Ljava/lang/String;Ljava/lang/String;)V + 27  28  return-void 29 .end method diff --git a/tests/snapshots/cli__samples_inline@helpful_1.el.snap b/tests/snapshots/cli__samples_inline@helpful_1.el.snap index d22bc49570..695eb5107f 100644 --- a/tests/snapshots/cli__samples_inline@helpful_1.el.snap +++ b/tests/snapshots/cli__samples_inline@helpful_1.el.snap @@ -20,6 +20,7 @@ input_file: sample_files/helpful_1.el 218  (insert 219  (helpful--heading "Source Code") 221  (if (eq helpful--sym canonical-sym) + 222  "Source Code" 223  "Alias Source Code")) 224  (cond 225  (source-path diff --git a/tests/snapshots/cli__samples_inline@html_1.html.snap b/tests/snapshots/cli__samples_inline@html_1.html.snap index 5e5f67481f..4018bd550d 100644 --- a/tests/snapshots/cli__samples_inline@html_1.html.snap +++ b/tests/snapshots/cli__samples_inline@html_1.html.snap @@ -5,25 +5,54 @@ input_file: sample_files/html_1.html --- sample_files/html_2.html --- 1/2 --- HTML 1   +2  <html> +3  <head> +4  <title>Example Domain +5  6  <!-- demo for tree-sitter --> +7  +8  <meta charset="utf-8" /> +9  <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> +10  <meta name="viewport" content="width=device-width, initial-scale=1" /> +11  <style type="text/css"> +12  body { 13  background-color: #f0f0f2; 14  margin: 0; 15  padding: 0; 16  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; +17  +18  } 19  div { +20  width: 600px; +21  margin: 5em auto; +22  padding: 2em; 23  background-color: #fdfdff; 1  + 2 <html> + 3  <head> + 4  <title>Example Domain + 5  6  <!-- demo for difftastic --> + 7  + 8  <meta charset="utf-8" /> + 9  <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> + 10  <meta name="viewport" content="width=device-width, initial-scale=1" /> 11  <style type="text/css"> 12  p { 13  color: #000; 14  } 15   + 16  <style type="text/css"> + 17  body { 18  background-color: #fdfdff; 19  margin: 10; 20  padding: 10; 21  font-family: Helvetica, Arial, sans-serif; + 22  } 23  #main { + 24  width: 600px; + 25  margin: 5em auto; + 26  padding: 2em; 27  background-color: #f0f0f2; 28  border-radius: 0.5em; 29  box-shadow: 2px 3px 7px 2px rgba(0, 0, 0, 0.02); @@ -36,16 +65,25 @@ input_file: sample_files/html_1.html 39  40  <body> 41  <div> +42  <h1>Example Domain 43  <p>This domain is for use in illustrative examples in documents. You may use this 44      domain in literature without prior coordination or asking for permission. 45  <p><a href="https://www.iana.org/domains/example">More information... +46  47  <script>alert('welcome!'); 46  <div id="main"> + 47  <h1>Example Domain 48  <p> + 49  This domain is for use in illustrative examples in documents. You may 50        use this domain in literature without prior coordination or asking for 51   permission. + 52  53  <p> 54  <a href="https://www.iana.org/domains/example?utm_src=example-dot-org" + 55  >More information... + 57  + 58  59  <script> 60  alert("goodbye!"); 61  diff --git a/tests/snapshots/cli__samples_inline@html_simple_1.html.snap b/tests/snapshots/cli__samples_inline@html_simple_1.html.snap index 71e2406ef7..d8912274c3 100644 --- a/tests/snapshots/cli__samples_inline@html_simple_1.html.snap +++ b/tests/snapshots/cli__samples_inline@html_simple_1.html.snap @@ -7,10 +7,12 @@ input_file: sample_files/html_simple_1.html 1  <html> 2  <head> 3  <title>Hi! +4  5  <body class="foo"> 6  <h1>Foo 7  <p>Story about foo. 3  <title>Hi + 4  5 <body class="bar"> 6  <h1 id="title">Bar 7  <p>Story about <strong>bar. diff --git a/tests/snapshots/cli__samples_inline@javascript_1.js.snap b/tests/snapshots/cli__samples_inline@javascript_1.js.snap index 9c878b19cd..0ab1f7cbfc 100644 --- a/tests/snapshots/cli__samples_inline@javascript_1.js.snap +++ b/tests/snapshots/cli__samples_inline@javascript_1.js.snap @@ -20,10 +20,12 @@ input_file: sample_files/javascript_1.js 16  done(); 17  }); 18  }); +19  20  test("Creating pages", done => { 19  test("/edit POST", done => { 20  db.createPage("EditAuthExample", "foo bar", (err, page) => { 21  expect(err).toBeNull(); + 22  23  request(app) 24  .post("/edit/" + page.rowid) 25  .type("form") @@ -35,6 +37,7 @@ input_file: sample_files/javascript_1.js 31  }); 32  }); 33  }); + 34  35  test("/new GET", done => { 36  request(app) 37  .get("/new") @@ -74,7 +77,14 @@ input_file: sample_files/javascript_1.js 69  }); 70  }); 71  }); + 94  95 describe("Viewing", () => { + 96  test("/all", done => { + 97  request(app) + 98  .get("/all") + 99  .expect(200, done); + 100  }); + 101  102  test("/AnExamplePage", done => { 103  db.createPage("AnExamplePage", "foo bar", () => { 104  request(app) diff --git a/tests/snapshots/cli__samples_inline@javascript_simple_1.js.snap b/tests/snapshots/cli__samples_inline@javascript_simple_1.js.snap index 266203fb09..0aefe87186 100644 --- a/tests/snapshots/cli__samples_inline@javascript_simple_1.js.snap +++ b/tests/snapshots/cli__samples_inline@javascript_simple_1.js.snap @@ -5,11 +5,19 @@ input_file: sample_files/javascript_simple_1.js --- sample_files/javascript_simple_2.js --- JavaScript 1  // hello +2  foo(); 3  bar(1); +4  baz(); +5  +6  var people = [ 7  "john", "harry", "dick", "eric", 2 if (true) { + 3  foo(); 4  bar(2); + 5  baz(); 6 } + 7  + 8 var people = [ 9  "john", "harry", "dick", "yvonne", 10  "eric", "jenny", "alexandra", 11 ]; diff --git a/tests/snapshots/cli__samples_inline@jsx_1.jsx.snap b/tests/snapshots/cli__samples_inline@jsx_1.jsx.snap index 5cb100be6f..2e70743499 100644 --- a/tests/snapshots/cli__samples_inline@jsx_1.jsx.snap +++ b/tests/snapshots/cli__samples_inline@jsx_1.jsx.snap @@ -6,8 +6,21 @@ input_file: sample_files/jsx_1.jsx sample_files/jsx_2.jsx --- JavaScript JSX 1  ReactDOM.render( 2 

Hello, world!, +3  document.getElementById("root")); +4  +5  var x = ( 6  <div> +7 

+8  foo +9   10  ); 2 

+ 3  <span>Hello, world! 4  , + 5  document.getElementById("root") + 6 ); + 7  + 8 var x = ( + 9 

+ 10  foo 11  ); diff --git a/tests/snapshots/cli__samples_inline@julia_1.jl.snap b/tests/snapshots/cli__samples_inline@julia_1.jl.snap index a4d790a621..8dcca9d38e 100644 --- a/tests/snapshots/cli__samples_inline@julia_1.jl.snap +++ b/tests/snapshots/cli__samples_inline@julia_1.jl.snap @@ -7,6 +7,7 @@ input_file: sample_files/julia_1.jl 25  israwtext(::MIME, x::AbstractString) = true 26  israwtext(::MIME"text/plain", x::AbstractString) = false 27  israwtext(::MIME, x) = false + 28  29 InlineIOContext(io, KVs::Pair...) = IOContext( 30  io, 31  :limit=>true, :color=>true, :jupyter=>true, @@ -23,8 +24,20 @@ input_file: sample_files/julia_1.jl 35  return String(x) 36  else 37  show(IOContext(buf, :limit=>true, :color=>true), mime, x) +38  end +39  else +40  b64 = Base64EncodePipe(buf) +41  if isa(x, Vector{UInt8}) +42  write(b64, x) # x assumed to be raw binary data +43  else 44  show(IOContext(b64, :limit=>true, :color=>true), mime, x) 43  show(InlineIOContext(buf), mime, x) + 44  end + 45  else + 46  b64 = Base64EncodePipe(buf) + 47  if isa(x, Vector{UInt8}) + 48  write(b64, x) # x assumed to be raw binary data + 49  else 50  show(InlineIOContext(b64), mime, x) 51  end 52  close(b64) diff --git a/tests/snapshots/cli__samples_inline@load_1.js.snap b/tests/snapshots/cli__samples_inline@load_1.js.snap index 4838cb2490..5dce56c79d 100644 --- a/tests/snapshots/cli__samples_inline@load_1.js.snap +++ b/tests/snapshots/cli__samples_inline@load_1.js.snap @@ -7,6 +7,14 @@ input_file: sample_files/load_1.js 11  var models = require("./models.js"); 12  13  var total = 0; +14  +15  var MIME_TYPES = { +16  ".css": "text/css", +17  ".html": "text/html", +18  ".js": "application/javascript", +19  "": "text/x-markdown", +20  }; +21  22  // Write localPath to the database. 23  // 24  // If no resourcePath is provided, convert "node_modules/foo/bar.js" to @@ -15,7 +23,16 @@ input_file: sample_files/load_1.js 27  if (resourcePath == null) { 28  resourcePath = path.relative("node_modules", localPath); 29  } +30  + 14  15 function createResource(resourcePath, localPath) { + 16  var MIME_TYPES = { + 17  ".css": "text/css", + 18  ".html": "text/html", + 19  ".js": "application/javascript", + 20  "": "text/x-markdown", + 21  }; + 22  23  return function (cb) { 24  total++; 25  new models.Resource({ @@ -26,6 +43,7 @@ input_file: sample_files/load_1.js 41  }).save(cb); 42  }; 43  } +44  45  function createResource(resourcePath, localPath) { 46  return function (cb) { 47  total++; @@ -52,85 +70,192 @@ input_file: sample_files/load_1.js 93  94  // Base codemirror 95  createNodeModuleResource( +96  "node_modules/codemirror/lib/codemirror.css" +97  ), 98  createNodeModuleResource("node_modules/codemirror/lib/codemirror.js"), +99  +100  // Editor conveniences 101  createNodeModuleResource( +102  "node_modules/codemirror/addon/edit/closebrackets.js" +103  ), 104  createNodeModuleResource( +105  "node_modules/codemirror/addon/edit/matchbrackets.js" +106  ), 107  createNodeModuleResource( +108  "node_modules/codemirror/addon/selection/active-line.js" +109  ), +110  +111  // Linting in editor. 112  createNodeModuleResource( +113  "node_modules/codemirror/addon/lint/lint.css" +114  ), 115  createNodeModuleResource( +116  "node_modules/codemirror/addon/lint/lint.js" +117  ), 118  createNodeModuleResource( +119  "node_modules/codemirror/addon/lint/javascript-lint.js" +120  ), +121  +122  // Basic, dumb completion (dabbrev style). 123  createNodeModuleResource( +124  "node_modules/codemirror/addon/hint/show-hint.css" +125  ), 126  createNodeModuleResource( +127  "node_modules/codemirror/addon/hint/show-hint.js" +128  ), 129  createNodeModuleResource( +130  "node_modules/codemirror/addon/hint/anyword-hint.js" +131  ), 132  createNodeModuleResource( +133  "node_modules/codemirror/addon/hint/css-hint.js" +134  ), 135  createNodeModuleResource( +136  "node_modules/codemirror/addon/hint/html-hint.js" +137  ), 138  createNodeModuleResource( +139  "node_modules/codemirror/addon/hint/xml-hint.js" +140  ), +141  +142  // Syntax highlighting 143  createNodeModuleResource( +144  "node_modules/codemirror/mode/javascript/javascript.js" +145  ), 146  createNodeModuleResource("node_modules/codemirror/mode/meta.js"), 147  createNodeModuleResource( +148  "node_modules/codemirror/mode/markdown/markdown.js" +149  ), 150  createNodeModuleResource("node_modules/codemirror/mode/xml/xml.js"), 151  createNodeModuleResource("node_modules/codemirror/mode/css/css.js"), +152  153  createNodeModuleResource("node_modules/requirejs/require.js"), +154  155  createNodeModuleResource( 156  "node_modules/backbone/backbone.js", +157  "backbone.js" +158  ), +159  160  createNodeModuleResource( 161  "node_modules/underscore/underscore.js", +162  "underscore.js" +163  ), +164  165  createNodeModuleResource( +166  "node_modules/jquery/dist/jquery.js", 167  "jquery.js" +168  ), +169  170  createNodeModuleResource( 171  "node_modules/marked/lib/marked.js", 172  "marked/marked.js" +173  ), +174  175  createNodeModuleResource( 176  "node_modules/handlebars/dist/handlebars.js", 177  "handlebars/handlebars.js" 72  createResource( 73  "codemirror/lib/codemirror.css", + 74  "node_modules/codemirror/lib/codemirror.css" + 75  ), 76  createResource( 77  "codemirror/lib/codemirror.js", + 78  "node_modules/codemirror/lib/codemirror.js" + 79  ), + 80  + 81  // Editor conveniences 82  createResource( 83  "codemirror/addon/edit/closebrackets.js", + 84  "node_modules/codemirror/addon/edit/closebrackets.js" + 85  ), 86  createResource( 87  "codemirror/addon/edit/matchbrackets.js", + 88  "node_modules/codemirror/addon/edit/matchbrackets.js" + 89  ), 90  createResource( 91  "codemirror/addon/selection/active-line.js", + 92  "node_modules/codemirror/addon/selection/active-line.js" + 93  ), + 94  + 95  // Linting in editor. 96  createResource( 97  "codemirror/addon/lint/lint.css", + 98  "node_modules/codemirror/addon/lint/lint.css" + 99  ), 100  createResource( 101  "codemirror/addon/lint/lint.js", + 102  "node_modules/codemirror/addon/lint/lint.js" + 103  ), 104  createResource( 105  "codemirror/addon/lint/javascript-lint.js", + 106  "node_modules/codemirror/addon/lint/javascript-lint.js" + 107  ), + 108  + 109  // Basic, dumb completion (dabbrev style). 110  createResource( 111  "codemirror/addon/hint/show-hint.css", + 112  "node_modules/codemirror/addon/hint/show-hint.css" + 113  ), 114  createResource( 115  "codemirror/addon/hint/show-hint.js", + 116  "node_modules/codemirror/addon/hint/show-hint.js" + 117  ), 118  createResource( 119  "codemirror/addon/hint/anyword-hint.js", + 120  "node_modules/codemirror/addon/hint/anyword-hint.js" + 121  ), 122  createResource( 123  "codemirror/addon/hint/css-hint.js", + 124  "node_modules/codemirror/addon/hint/css-hint.js" + 125  ), 126  createResource( 127  "codemirror/addon/hint/html-hint.js", + 128  "node_modules/codemirror/addon/hint/html-hint.js" + 129  ), 130  createResource( 131  "codemirror/addon/hint/xml-hint.js", + 132  "node_modules/codemirror/addon/hint/xml-hint.js" + 133  ), + 134  + 135  // Syntax highlighting 136  createResource( 137  "codemirror/mode/javascript/javascript.js", + 138  "node_modules/codemirror/mode/javascript/javascript.js" + 139  ), 140  createResource( 141  "codemirror/mode/meta.js", + 142  "node_modules/codemirror/mode/meta.js" + 143  ), 144  createResource( 145  "codemirror/mode/markdown/markdown.js", + 146  "node_modules/codemirror/mode/markdown/markdown.js" + 147  ), 148  createResource( 149  "codemirror/mode/xml/xml.js", + 150  "node_modules/codemirror/mode/xml/xml.js" + 151  ), 152  createResource( 153  "codemirror/mode/css/css.js", + 154  "node_modules/codemirror/mode/css/css.js" + 155  ), + 156  157  createResource( 158  "requirejs/require.js", + 159  "node_modules/requirejs/require.js" + 160  ), + 161  162  createResource("backbone.js", "node_modules/backbone/backbone.js"), + 163  164  createResource( 165  "underscore.js", 166  "node_modules/underscore/underscore.js" + 167  ), + 168  169  createResource("jquery.js", "node_modules/jquery/dist/jquery.js"), + 170  171  createResource( 172  "marked/marked.js", 173  "node_modules/marked/lib/marked.js" + 174  ), + 175  176  createResource( 177  "handlebars/handlebars.js", 178  "node_modules/handlebars/dist/handlebars.js" @@ -143,12 +268,16 @@ input_file: sample_files/load_1.js 191  mimeType: "image/png", 192  localPath: "icons/Error-48.png", 193  }), +194  195  createNodeModuleResource("node_modules/mocha/mocha.js"), 196  createNodeModuleResource("node_modules/mocha/mocha.css"), +197  + 195  196  // TODO: it would be nice to have more systematic naming 197  // of our paths, based on the node_modules path. 198  createResource("mocha/mocha.js", "node_modules/mocha/mocha.js"), 199  createResource("mocha/mocha.css", "node_modules/mocha/mocha.css"), + 200  201  createResource("metawiki/index.html", "src/frontend/index.html"), 202  203  // TODO: use globbing rather than spelling this out. diff --git a/tests/snapshots/cli__samples_inline@lua_1.lua.snap b/tests/snapshots/cli__samples_inline@lua_1.lua.snap index 1ab802d611..6778fca980 100644 --- a/tests/snapshots/cli__samples_inline@lua_1.lua.snap +++ b/tests/snapshots/cli__samples_inline@lua_1.lua.snap @@ -6,16 +6,28 @@ input_file: sample_files/lua_1.lua sample_files/lua_2.lua --- Lua 1  function test() 2  print("testing") +3  return 10 +4  end +5  6  if test() == 20 then 7  print("30") +8  end +9  10  local list = { "A", "B", "D" } 11  local table = { a = "A", b = "B", d = "D" } +12  1 function test(name) 2  print("testing"..name) + 3  return 10 + 4 end + 5  6 if test("myname") == 20 then 7  print("20") + 8 end + 9  10 local list = { "A", "B", "C", "D" } 11 local table = { a = "A", b = "B", c = "C", d = "D" } + 12  13 for k, v in pairs(table) do 14  print("k: "..k.." v: "..v) 15 end diff --git a/tests/snapshots/cli__samples_inline@metadata_1.clj.snap b/tests/snapshots/cli__samples_inline@metadata_1.clj.snap index 5e08107107..06448b9cdf 100644 --- a/tests/snapshots/cli__samples_inline@metadata_1.clj.snap +++ b/tests/snapshots/cli__samples_inline@metadata_1.clj.snap @@ -8,7 +8,10 @@ input_file: sample_files/metadata_1.clj 2  "Utilities for formatting binary data (byte arrays) or binary deltas." 3  (:require [io.aviso.ansi :as ansi] 4  [io.aviso.columns :as c])) +5  + 4  [io.aviso.columns :as c]) 5  (:import (java.nio ByteBuffer))) + 6  7 (defprotocol BinaryData 8  "Allows various data sources to be treated as a byte-array data type that 9  supports a length and random access to individual bytes. @@ -17,6 +20,7 @@ input_file: sample_files/metadata_1.clj 16  BinaryData 17  (data-length [ary] (alength (bytes ary))) 18  (byte-at [ary index] (aget (bytes ary) index))) + 20  21 (extend-type ByteBuffer 22  BinaryData 23  (data-length [b] (.remaining b)) @@ -32,7 +36,9 @@ input_file: sample_files/metadata_1.clj 35  BinaryData 36  (data-length [_] 0) 37  (byte-at [_ index] (throw (IndexOutOfBoundsException. "Can't use byte-at with nil.")))) +38  43  (byte-at [_ _index] (throw (IndexOutOfBoundsException. "Can't use byte-at with nil.")))) + 44  45 (def ^:private ^:const bytes-per-diff-line 16) 46 (def ^:private ^:const bytes-per-ascii-line 16) 47 (def ^:private ^:const bytes-per-line (* 2 bytes-per-diff-line)) diff --git a/tests/snapshots/cli__samples_inline@nested_slider_1.rs.snap b/tests/snapshots/cli__samples_inline@nested_slider_1.rs.snap index 8da3ed5505..9f28ad075d 100644 --- a/tests/snapshots/cli__samples_inline@nested_slider_1.rs.snap +++ b/tests/snapshots/cli__samples_inline@nested_slider_1.rs.snap @@ -6,8 +6,18 @@ input_file: sample_files/nested_slider_1.rs sample_files/nested_slider_2.rs --- Rust 1  fn split_string_by_codepoint_brace() { 2  if true { +3  x; +4  } +5  } +6  +7  fn split_string_by_codepoint_paren() { 8  foo(x) 3  if pad_last { + 4  x; 5  } + 6  } + 7 } + 8  + 9 fn split_string_by_codepoint_paren() { 10  foo(bar(x)) 11 } diff --git a/tests/snapshots/cli__samples_inline@nesting_1.el.snap b/tests/snapshots/cli__samples_inline@nesting_1.el.snap index 98cba4280e..f7f7cd4e26 100644 --- a/tests/snapshots/cli__samples_inline@nesting_1.el.snap +++ b/tests/snapshots/cli__samples_inline@nesting_1.el.snap @@ -6,4 +6,5 @@ input_file: sample_files/nesting_1.el sample_files/nesting_2.el --- Emacs Lisp 2  (foo) 1 a + 2 b 3 foo diff --git a/tests/snapshots/cli__samples_inline@nix_1.nix.snap b/tests/snapshots/cli__samples_inline@nix_1.nix.snap index c2b23327e0..2d3f31afaf 100644 --- a/tests/snapshots/cli__samples_inline@nix_1.nix.snap +++ b/tests/snapshots/cli__samples_inline@nix_1.nix.snap @@ -9,8 +9,16 @@ input_file: sample_files/nix_1.nix 3  rustPlatform.buildRustPackage rec { 4  pname = "difftastic"; 5  version = "0.12.0"; +6  +7  src = fetchFromGitHub { +8  owner = "wilfred"; +9  repo = pname; +10  rev = version; 11  sha256 = "sha256-A6Z3g6fbYBynyN4OhRrZNO0ZghvT3XnIahdUQ8SE8tU="; +12  }; +13  14  cargoSha256 = "sha256-6/JwrPymtpj/CXqx3Pe43v+MJTNONArU2WEo/zgJhT4="; +15  16  postPatch = '' 17   pushd vendor 18   for grammar in */; do @@ -21,9 +29,18 @@ input_file: sample_files/nix_1.nix 23   done 24   popd 25   ''; +26  5  version = "0.24.0"; + 6  + 7  src = fetchFromGitHub { + 8  owner = "wilfred"; + 9  repo = pname; + 10  rev = version; 11  sha256 = "sha256-Yp0WwzGo8nuRZuiHdUPxPM1SYBeeVA3SMDfHnQmqUqY="; + 12  }; + 13  14  cargoSha256 = "sha256-m80PT2UQYhA5KEh7ax/fhh6vuse0DXhbFsh2x4pwkWY="; + 15  16  meta = with lib; { 17  description = "A syntax-aware diff"; 18  homepage = "https://github.com/Wilfred/difftastic"; diff --git a/tests/snapshots/cli__samples_inline@objc_header_1.h.snap b/tests/snapshots/cli__samples_inline@objc_header_1.h.snap index 0377383f2d..ca389b55ed 100644 --- a/tests/snapshots/cli__samples_inline@objc_header_1.h.snap +++ b/tests/snapshots/cli__samples_inline@objc_header_1.h.snap @@ -6,7 +6,11 @@ input_file: sample_files/objc_header_1.h sample_files/objc_header_2.h --- 1/2 --- Objective-C 1  // 2  //  HttpServer.h +3  // +4  // Created by Nicholas Moore on 20/09/2022. 2 //  HttpServer.h after file + 3 // + 4 // Created by Nicholas Moore on 20/09/2022. 5 // A line added to the header. 6 // 7 // Added to difftastic test suite by the author. @@ -19,11 +23,23 @@ input_file: sample_files/objc_header_1.h 13  typedef NSDictionary *_Nullable(^PopHttpRequestHandler)(NSURL *url, NSString *method, NSDictionary *headers, NSData *body); 14  15  @interface PopHttpServer : NSObject +16  @property (readonly) uint16_t port; +17  @property (readonly) NSString *lastError; +18  @property (readonly, getter=isListening) BOOL listening; +19  - (id)initWithPort:(uint16_t)port; +20  - (BOOL)start; +21  - (void)stop; 22  - (void)registerHandler:(NSString *)pathPrefix block:(PopHttpRequestHandler)myblock; 19 @interface PopHttpServer : NSObjectqq 20 @property(readonly) uint16_t port; // comment 21 @property(readonly) NSString *host; + 22 @property(readonly) NSString *lastError; + 23 @property(readonly, getter=isListening) BOOL listening; + 24 - (id)initWithPort:(uint16_t)port; + 25 - (BOOL)start; + 26 - (void)stop; 27 - (void)registerHandler:(NSString *_Nonnull)pathPrefix + 28  block:(PopHttpRequestHandler)myblock 29  added:(BOOL *_Nullable)added; 30 @end 31  diff --git a/tests/snapshots/cli__samples_inline@ocaml_1.ml.snap b/tests/snapshots/cli__samples_inline@ocaml_1.ml.snap index c8e96c0f18..3f0c898587 100644 --- a/tests/snapshots/cli__samples_inline@ocaml_1.ml.snap +++ b/tests/snapshots/cli__samples_inline@ocaml_1.ml.snap @@ -9,7 +9,30 @@ input_file: sample_files/ocaml_1.ml 4  type foo = 5  | Bar 6  | Baz of int * ('ex, 'en) list +7  | Biz of ('ex, 'en) list +8  +9  let do_stuff x = +10  match x with +11  | `Foo -> 1 12  | `Bar -> 2 +13  | _ -> 3 +14  +15  let stuffs y = +16  y + 1 +17  +18  type thing = 19  | X + 6  | Biz of ('ex, 'en) list + 7  + 8 let do_stuff x = + 9  match x with + 10  | `Foo -> 1 + 11  | _ -> 3 + 12  + 13 let stuffs y = + 14  y + 1 + 15  + 16 type thing = 17  | X [@visitor.opaque] + 18  | Y 19 [@@visitor.opaque] diff --git a/tests/snapshots/cli__samples_inline@outer_delimiter_1.el.snap b/tests/snapshots/cli__samples_inline@outer_delimiter_1.el.snap index 141f8e0edf..5efb0cc3e8 100644 --- a/tests/snapshots/cli__samples_inline@outer_delimiter_1.el.snap +++ b/tests/snapshots/cli__samples_inline@outer_delimiter_1.el.snap @@ -5,4 +5,5 @@ input_file: sample_files/outer_delimiter_1.el --- sample_files/outer_delimiter_2.el --- Emacs Lisp 1 (foo + 2  (read) 3  ) diff --git a/tests/snapshots/cli__samples_inline@pascal_1.pascal.snap b/tests/snapshots/cli__samples_inline@pascal_1.pascal.snap index 93795b453a..7df35e7667 100644 --- a/tests/snapshots/cli__samples_inline@pascal_1.pascal.snap +++ b/tests/snapshots/cli__samples_inline@pascal_1.pascal.snap @@ -10,7 +10,13 @@ input_file: sample_files/pascal_1.pascal 15  else begin 16  if K > N - K then 17  K:= N - K; // Optimization +18  Result:= 1; +19  L:= 0; +20  while L < K do begin 21  Result:= Result * (N - L); + 16  Result:= 1; + 17  L:= 0; + 18  while L < K do begin 19  Result:= Result * (N - 1); 20  Inc(L); 21  Result:= Result div L; diff --git a/tests/snapshots/cli__samples_inline@perl_1.pl.snap b/tests/snapshots/cli__samples_inline@perl_1.pl.snap index 29bc052483..10af9cd634 100644 --- a/tests/snapshots/cli__samples_inline@perl_1.pl.snap +++ b/tests/snapshots/cli__samples_inline@perl_1.pl.snap @@ -9,10 +9,32 @@ input_file: sample_files/perl_1.pl 10  11  use constant { 12  SEC => 0, # foo bar +13  MIN => 1, +14  HOUR => 2, +15  MDAY => 3, +16  MON => 4, +17  YEAR => 5, +18  WDAY => 6, +19  YDAY => 7, 20  ISDST => 8, +21  }; +22  +23  use constant WEEKDAYS => qw( +24  Sunday Monday Tuesday Wednesday Thursday Friday Saturday +25  ); +26  27  $f =~ s/foo/bar/g; 12  SEC => 0, # foo + 13  MIN => 1, + 14  HOUR => 2, + 15  MDAY => 3, + 16  MON => 4, + 17  YEAR => 5, + 18  WDAY => 6, + 19  YDAY => 7, 20  ISDST => 10, + 21 }; + 22  23 my $setting = { 24  open => 1, 25  close => 2, @@ -22,6 +44,12 @@ input_file: sample_files/perl_1.pl 29 my %final; 30 foreach my $key (woof()) { 31  $final{IRONMAN}{$key} = $setting->{$key}; + 32  33  print Dumper \%final; 34 } + 35  + 36 use constant WEEKDAYS => qw( + 37  Sunday Monday Tuesday Wednesday Thursday Friday Saturday + 38 ); + 39  40 $f =~ s/foo/abc/g; diff --git a/tests/snapshots/cli__samples_inline@prefer_outer_1.el.snap b/tests/snapshots/cli__samples_inline@prefer_outer_1.el.snap index 6fb20ca2f6..eb5a99db6d 100644 --- a/tests/snapshots/cli__samples_inline@prefer_outer_1.el.snap +++ b/tests/snapshots/cli__samples_inline@prefer_outer_1.el.snap @@ -6,7 +6,13 @@ input_file: sample_files/prefer_outer_1.el sample_files/prefer_outer_2.el --- Emacs Lisp 1  (defun deadgrep--find-file (path) 2  (save-match-data +3  (let* ((initial-buffers (buffer-list)) 4  (buf (save-match-data (find-file-noselect path)))) +5  (unless (-contains-p initial-buffers buf) +6  (setq opened t)) 7  (cons buf opened)))) + 2  (let* ((initial-buffers (buffer-list)) 3  (buf (find-file-noselect path))) + 4  (unless (-contains-p initial-buffers buf) + 5  (setq opened t)) 6  (cons buf opened))) diff --git a/tests/snapshots/cli__samples_inline@qml_1.qml.snap b/tests/snapshots/cli__samples_inline@qml_1.qml.snap index f1d47a8f70..053df4c62a 100644 --- a/tests/snapshots/cli__samples_inline@qml_1.qml.snap +++ b/tests/snapshots/cli__samples_inline@qml_1.qml.snap @@ -7,8 +7,10 @@ input_file: sample_files/qml_1.qml 1  // Taken from https://doc.qt.io/qt-6/qmlapplications.html 2  import QtQuick 3  import QtQuick.Controls +4  2 import QtQuick 2.15 3 import QtQuick.Controls 2.15 + 4  5 ApplicationWindow { 6  width: 400 7  height: 400 @@ -18,14 +20,26 @@ input_file: sample_files/qml_1.qml 9  10  Button { 11  id: button +12  text: "A Special Button" +13  background: Rectangle { +14  implicitWidth: 100 +15  implicitHeight: 40 16  color: button.down ? "#d6d6d6" : "#f6f6f6" +17  border.color: "#26282a" +18  border.width: 1 12  hoverEnabled: true + 13  text: "A Special Button" + 14  background: Rectangle { + 15  implicitWidth: 100 + 16  implicitHeight: 40 17  color: { 18  if (button.down || button.hovered) { 19  "#d6d6d6" 20  } else { + 21  "#f6f6f6" 22  } 23  } + 24  border.color: "#26282a" 25  border.width: button.down ? 2 : 1 26  radius: 4 27  } diff --git a/tests/snapshots/cli__samples_inline@racket_1.rkt.snap b/tests/snapshots/cli__samples_inline@racket_1.rkt.snap index 354d6145dc..3d02516c63 100644 --- a/tests/snapshots/cli__samples_inline@racket_1.rkt.snap +++ b/tests/snapshots/cli__samples_inline@racket_1.rkt.snap @@ -5,23 +5,35 @@ input_file: sample_files/racket_1.rkt --- sample_files/racket_2.rkt --- Racket 1  #lang racket/base +2  +3  (define (append lst1 lst2) 4  (cond [(null? lst1) lst2] 5  [else (cons (car lst1) 6  (append (cdr lst1) lst2))])) +7  8  (append '(a b c) '(d e)) +9  10  "Hello, world!" +11  #(1 2 3) 12  #\" +13  14  #<<END 15  abc 16  END 1 #lang racket + 2  + 3 (define (append lst1 lst2) 4  (if (null? lst1) + 5  lst2 6  (cons (car lst1) 7  (append (cdr lst1) lst2)))) + 8  9 (append '(a b c) '(d e f)) + 10  11 "Hello, world!\n" 12 #(0 1 2 3 4) 13 #\space + 14  15 #<<E 16 abc 17 E diff --git a/tests/snapshots/cli__samples_inline@scala_1.scala.snap b/tests/snapshots/cli__samples_inline@scala_1.scala.snap index a12629d1fd..9bc41e6bf8 100644 --- a/tests/snapshots/cli__samples_inline@scala_1.scala.snap +++ b/tests/snapshots/cli__samples_inline@scala_1.scala.snap @@ -8,15 +8,33 @@ input_file: sample_files/scala_1.scala 2  3  // A Scala program. 4  import foo.Bar +5  +6  class Foo { +7  8  def blah(): Int { +9  /* foo */ 10  throw new Exception("before"); +11  } +12  +13  var result = Option.empty[T] +14  object traverser extends SimpleTraverser { +15  override def apply(t: Tree): Unit = { 16  if (result.isEmpty && pf.isDefinedAt(t)) { 17  result = Some(pf(t)) 18  } else if (result.isEmpty) { 4 import foo.Baz + 5  + 6 class Foo { + 7  8  private def blah(): Other { + 9  /* foo */ 10  throw new Exception("after"); + 11  } + 12  + 13  var result = Option.empty[T] 14  val fn = pf.lift + 15  object traverser extends SimpleTraverser { + 16  override def apply(t: Tree): Unit = { 17  result = fn(t).orElse(result) 18  if (result.nonEmpty) { 19  super.apply(t) diff --git a/tests/snapshots/cli__samples_inline@simple_1.scss.snap b/tests/snapshots/cli__samples_inline@simple_1.scss.snap index d90e21f9b7..8fde57fc15 100644 --- a/tests/snapshots/cli__samples_inline@simple_1.scss.snap +++ b/tests/snapshots/cli__samples_inline@simple_1.scss.snap @@ -5,10 +5,18 @@ input_file: sample_files/simple_1.scss --- sample_files/simple_2.scss --- 1/2 --- SCSS 1  @mixin buttons($basicBorder:1px, $gradient1:#fff, $gradient2:#d8dee7){ +2  button{ 3  border:$basicBorder solid #acbed3; +4  //brings in Compass' background-image mixin: http://compass-style.org/reference/compass/css3/images/ +5  @include background-image(linear-gradient($gradient1, $gradient2)); +6  padding:3px 14px; 7  font-size:12px; 1 @mixin buttons($basicBorder:1px, $gradient1:#333, $gradient2:#d8dee7){ + 2  button{ 3  border:$basicBorder dotted #acbed3; + 4  //brings in Compass' background-image mixin: http://compass-style.org/reference/compass/css3/images/ + 5  @include background-image(linear-gradient($gradient1, $gradient2)); + 6  padding:3px 14px; 7  font-size:1rem; 8  color:#3b557d; 9  //brings in Compass' border-radius mixin: http://compass-style.org/reference/compass/css3/border_radius/ @@ -21,8 +29,18 @@ input_file: sample_files/simple_1.scss 14  15  &.primary { 16  border:2px solid #3b557d; +17  padding:5px 15px; +18  //requires a $border-radius variable +19  @include border-radius($border-radius + 2, $border-radius + 2); +20  } +21  &.disabled { 22  opacity: .8; 16  border:2px dotted #3b557d; + 17  padding:5px 15px; + 18  //requires a $border-radius variable + 19  @include border-radius($border-radius + 2, $border-radius + 2); + 20  } + 21  &.disabled { 22  opacity: .6; 23  } 24  &:hover { diff --git a/tests/snapshots/cli__samples_inline@slider_at_end_1.json.snap b/tests/snapshots/cli__samples_inline@slider_at_end_1.json.snap index d2eacd9901..c893f5b4b8 100644 --- a/tests/snapshots/cli__samples_inline@slider_at_end_1.json.snap +++ b/tests/snapshots/cli__samples_inline@slider_at_end_1.json.snap @@ -7,6 +7,7 @@ input_file: sample_files/slider_at_end_1.json 1  [ 2  "one", 3  "novel-1", +4  "two", 5  "novel-2", 4  "three" 5 ] diff --git a/tests/snapshots/cli__samples_inline@string_subwords_1.el.snap b/tests/snapshots/cli__samples_inline@string_subwords_1.el.snap index 6cdbd18a3c..df7a805c63 100644 --- a/tests/snapshots/cli__samples_inline@string_subwords_1.el.snap +++ b/tests/snapshots/cli__samples_inline@string_subwords_1.el.snap @@ -5,11 +5,17 @@ input_file: sample_files/string_subwords_1.el --- sample_files/string_subwords_2.el --- Emacs Lisp 1  (format "SoloWiki Viewing: %s" name) +2  +3  (defcustom deadgrep-max-buffers +4  4 5  "Deadgrep will kill the least recently used results buffer 6  if there are more than this many. 7  8  To disable cleanup entirely, set this variable to nil." 1 (format "%s: %s" (site-name) name) + 2  + 3 (defcustom deadgrep-max-buffers + 4  4 5  "The maximum number of deadgrep results buffers. 6  7 If the number of results buffers exceeds this value, deadgrep diff --git a/tests/snapshots/cli__samples_inline@text_1.txt.snap b/tests/snapshots/cli__samples_inline@text_1.txt.snap index 365c557f79..217b4c2917 100644 --- a/tests/snapshots/cli__samples_inline@text_1.txt.snap +++ b/tests/snapshots/cli__samples_inline@text_1.txt.snap @@ -5,8 +5,12 @@ input_file: sample_files/text_1.txt --- sample_files/text_2.txt --- Text 1  hello +2  world +3  4  foo 5  c07e640b246c7885cbc3d5c627acbcb2d2ab9c95 2 novel + 3 world + 4  5 foo bar 6 31df1778815171897c907daf454c4419cfaa46f9 diff --git a/tests/snapshots/cli__samples_inline@todomvc_1.gleam.snap b/tests/snapshots/cli__samples_inline@todomvc_1.gleam.snap index ab44b4ac32..c4e858fb7c 100644 --- a/tests/snapshots/cli__samples_inline@todomvc_1.gleam.snap +++ b/tests/snapshots/cli__samples_inline@todomvc_1.gleam.snap @@ -7,9 +7,15 @@ input_file: sample_files/todomvc_1.gleam 15  let application_secret = load_application_secret() 16  let db = start_database_connection_pool() 17  let web = routes.stack(application_secret, db) +18  +19  string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) 20  |> log.info +21  + 18  19  let log_string = + 20  string.concat(["Listening on localhost:", int.to_string(port), " ✨"]) 21  log.info(log_string) + 22  23  assert Ok(_) = elli.become(web, on_port: port) 24 } 25  diff --git a/tests/snapshots/cli__samples_inline@toml_1.toml.snap b/tests/snapshots/cli__samples_inline@toml_1.toml.snap index 7e1073a87b..0996579682 100644 --- a/tests/snapshots/cli__samples_inline@toml_1.toml.snap +++ b/tests/snapshots/cli__samples_inline@toml_1.toml.snap @@ -7,10 +7,22 @@ input_file: sample_files/toml_1.toml 1  # This is a TOML document 2  3  title = "TOML Example" +4  +5  [owner] +6  name = "Tom Preston-Werner" 7  dob = 1979-05-27T07:32:00-08:00 +8  +9  [database] +10  enabled = true 11  ports = [ 8000, 8001, 8002 ] 3 title = "TOML Example Changed" + 4  + 5 [owner] + 6 name = "Tom Preston-Werner" 7 dob = 2000-01-31T07:32:00-08:00 + 8  + 9 [database] + 10 enabled = true 11 ports = [ 8000, 8002 ] 12 data = [ ["delta", "phi"], [3.14] ] 13 temp_targets = { cpu = 79.5, case = 72.0 } @@ -27,4 +39,5 @@ input_file: sample_files/toml_1.toml 31   fox jumps over \ 32   the lazy dog.\ 33   """ +34  35  path = 'C:\Users\nodejs\templates' diff --git a/tests/snapshots/cli__samples_inline@vhdl_1.vhd.snap b/tests/snapshots/cli__samples_inline@vhdl_1.vhd.snap index 3ffe1beca2..3b9bea5f9b 100644 --- a/tests/snapshots/cli__samples_inline@vhdl_1.vhd.snap +++ b/tests/snapshots/cli__samples_inline@vhdl_1.vhd.snap @@ -9,20 +9,45 @@ input_file: sample_files/vhdl_1.vhd 6  port ( 7  clk: in std_logic; 8  led: out std_logic +9  ); +10  end entity; +11  +12  architecture a of blinky is 13  constant CLK_FREQ: positive := 12_000_000; 14  signal counter: unsigned(23 downto 0) := (others => '0'); +15  begin +16  process(clk) +17  begin +18  if rising_edge(clk) then 19  if to_integer(counter) = CLK_FREQ / 2 then 20  led <= not led; 21  counter <= (others => '0'); +22  else 23  counter <= counter + 1; +24  end if; +25  end if; +26  end process; 8  led: out std_logic_vector(3 downto 0) + 9  ); + 10 end entity; + 11  + 12 architecture a of blinky is 13  constant CLK_FREQ: positive := 48_000_000; 14  signal counter1: unsigned(25 downto 0) := (others => '0'); 15  signal counter2: unsigned(1 downto 0) := (others => '0'); + 16 begin + 17  process(clk) + 18  begin + 19  if rising_edge(clk) then 20  if to_integer(counter1) = CLK_FREQ / 2 then 21  counter2 <= counter2 + 1; 22  counter1 <= (others => '0'); + 23  else 24  counter1 <= counter1 + 1; + 25  end if; + 26  end if; + 27  end process; + 28  29  process(counter2) 30  begin 31  for n in 0 to 3 loop diff --git a/tests/snapshots/cli__samples_inline@yaml_1.yaml.snap b/tests/snapshots/cli__samples_inline@yaml_1.yaml.snap index 90e1c3547e..688c7a4cc9 100644 --- a/tests/snapshots/cli__samples_inline@yaml_1.yaml.snap +++ b/tests/snapshots/cli__samples_inline@yaml_1.yaml.snap @@ -6,8 +6,14 @@ input_file: sample_files/yaml_1.yaml sample_files/yaml_2.yaml --- YAML 1  --- 2  foo: [foobar] +3  hello: +4  - "world" +5  - other +6  7  stuff: | 8   a 9   b 2 foo: [bar, foobar] + 3 hello: + 4  - "world" 5  - 'item' diff --git a/tests/snapshots/cli__samples_inline@zig_1.zig.snap b/tests/snapshots/cli__samples_inline@zig_1.zig.snap index 381d47584b..9f454dae0e 100644 --- a/tests/snapshots/cli__samples_inline@zig_1.zig.snap +++ b/tests/snapshots/cli__samples_inline@zig_1.zig.snap @@ -6,6 +6,8 @@ input_file: sample_files/zig_1.zig sample_files/zig_2.zig --- Zig 2  std.debug.print("Hello, {s}!", .{"world"}); 1 const std = @import("std"); + 2  + 3 pub fn main() void { 4  std.debug.print("Hello, {s}!", .{"user"}); 5  std.debug.print("Hello, again!", .{}); 6 }