import { Position , Range , Selection , TextEditor , TextEditorDecorationType , ThemeColor , window } from 'vscode' ; param editor export const clearSelection = ( editor ) : void => { if ( hasSelection ( editor ) ) { editor . selections = [ new Selection ( new Position ( 0 , 0 ) , new Position ( 0 , 0 ) ) ] ; } } ; param editor return export const hasSelection = ( editor ) : boolean => { const isSelectionNone = editor ?. selections . reduce ( ( acc , cur ) => { return acc && cur . start . isEqual ( cur . end ) ; } , true ) ?? true ; return ! isSelectionNone ; } ; param editor return export const getSelectionStringDefinition = ( editor ) : string => { return editor . selections . reduce ( ( acc , cur ) => { const tmp = acc ? `${ acc }|` : '' ; return `${ tmp }${ cur . start . line + 1 }:${ cur . start . character }-${ cur . end . line + 1 }:${ cur . end . character }` ; } , '' ) ; } ; param editor return export const getSelectionRanges = ( editor ) : Range [ ] => { return editor . selections . map ( ( el ) => { return new Range ( el . start , el . end ) ; } ) ; } ; param text export const isValidColorDefinition = ( text ) : boolean => { const regexHex = /^#[0-9a-fA-F]{8}$|#[0-9a-fA-F]{6}$|#[0-9a-fA-F]{4}$|#[0-9a-fA-F]{3}$/gm ; const regexRgba = /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(1|(0(.\d{1,2})?))\)$/gm ; return regexHex . test ( text ) || regexRgba . test ( text ) ; } ; param priority returns export const themeColorForPriority = ( priority ) : ThemeColor | undefined => { switch ( priority ) { case 3 : return new ThemeColor ( 'codereview.priority.red' ) ; case 2 : return new ThemeColor ( 'codereview.priority.yellow' ) ; case 1 : return new ThemeColor ( 'codereview.priority.green' ) ; default : return undefined ; } } ; param priority returns export const symbolForPriority = ( priority ) : string | undefined => { switch ( priority ) { case 3 : return '⇡' ; case 2 : return '⇢' ; case 1 : return '⇣' ; default : return undefined ; } } ;