You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: erase_helpers.go
    path of file: ./repos/malice/vendor/github.com/Azure/go-ansiterm/winterm
    
    the code of the file until where you have to start completion: // +build windows

package winterm

import "github.com/Azure/go-ansiterm"

func (h *windowsAnsiEventHandler) clearRange(attributes uint16, fromCoord COORD, toCoord COORD) error {
	// Ignore an invalid (negative area) request
	if toCoord.Y < fromCoord.Y {
		return nil
	}

	var err error

	var coordStart = COORD{}
	var coordEnd = COORD{}

	xCurrent, yCurrent := fromCoord.X, fromCoord.Y
	xEnd, yEnd := toCoord.X, toCoord.Y

	// Clear any partial initial line
	if xCurrent > 0 {
		coordStart.X, coordStart.Y = xCurrent, yCurrent
		coordEnd.X, coordEnd.Y = xEnd, yCurrent

		err = h.clearRect(attributes, coordStart, coordEn
    
func (h *windowsAnsiEventHandler) clearRange(attributes uint16, fromCoord COORD, toCoord COORD) error {
	// Ignore an invalid (negative area) request
	if toCoord.Y < fromCoord.Y {
		return nil
	}

	var err error

	var coordStart = COORD{}
	var coordEnd = COORD{}

	xCurrent, yCurrent := fromCoord.X, fromCoord.Y
	xEnd, yEnd := toCoord.X, toCoord.Y

	// Clear any partial initial line
	if xCurrent > 0 {
		coordStart.X, coordStart.Y = xCurrent, yCurrent
		coordEnd.X, coordEnd.Y = xEnd, yCurrent

		err = h.clearRect(attributes, coordStart, coordEnd)
		if err != nil {
			return err
		}

		xCurrent = 0
		yCurrent += 1
	}

	// Clear intervening rectangular section
	if yCurrent < yEnd {
		coordStart.X, coordStart.Y = xCurrent, yCurrent
		coordEnd.X, coordEnd.Y = xEnd, yEnd-1

		err = h.clearRect(attributes, coordStart, coordEnd)
		if err != nil {
			return err
		}

		xCurrent = 0
		yCurrent = yEnd
	}

	// Clear remaining partial ending line
	coordStart.X, coordStart.Y = xCurrent, yCurrent
	coordEnd.X, coordEnd.Y = xEnd, yEnd

	err = h.clearRect(attributes, coordStart, coordEnd)
	if err != nil {
		return err
	}

	return nil
}