#!/bin/sh
# -*- tcl -*-
# The next line is executed by /bin/sh, but not tcl \
exec tclsh "$0" ${1+"$@"}

# Test for changing to a search target that maches at the start of a line.
#
# Was https://github.com/martinwguy/xvi/issues/154

source scripts/term
start_vi

# Command to reset the intiial test pattern
set init "1GdGathree\rone\rfour\rone\rfive[esc]2G"
# Match for the initial test pattern
set pattern [list "three" "one" "four" "one" "five" "~"]

# Make classic vi update the screen instead of leaving @ signs in deleted lines
exp_send ":se redraw\r"

# Change from start of line to start of line
test 30 $init		2 0 $pattern
test 31 "c/one\rX[esc]"	2 0 [list "three" "X" "one" "five" "~"]

# Change from middle of line to start of line
test 32 $init		2 0 $pattern
test 33 "lc/one\rX[esc]" 2 1 [list "three" "oX" "one" "five" "~"]
# nvi gets this wrong, giving 2 0 [list "three" "X" "one" "five"]

# Change from start of line to middle of next line
test 34 $init		2 0 $pattern
test 35 "c/ur\rX[esc]" 2 0 [list "three" "Xur" "one" "five" "~"]

stop_vi

exit 0
