import * as vscode from 'vscode' ; import * as positionUtils from './position_utils' ; export function setVisualSelections ( editor , originalSelections ) { editor . selections = editor . selections . map ( ( selection , i ) => { const originalSelection = originalSelections [ i ] ; let activePosition = selection . active ; if ( ! selection . isReversed && selection . active . character === 0 ) { activePosition = positionUtils . right ( editor . document , selection . active ) ; } if ( originalSelection . active . isBefore ( originalSelection . anchor ) && selection . active . isAfterOrEqual ( selection . anchor ) ) { return new vscode . Selection ( positionUtils . left ( selection . anchor ) , activePosition ) ; } else if ( originalSelection . active . isAfter ( originalSelection . anchor ) && selection . active . isBeforeOrEqual ( selection . anchor ) ) { return new vscode . Selection ( positionUtils . right ( editor . document , selection . anchor ) , activePosition ) ; } else { return new vscode . Selection ( selection . anchor , activePosition ) ; } } ) ; }