import { CharacterSet } from './CharacterSet' ; import { characterSetsToTabOutFrom } from './charactersToTabOutFrom' ; import { window , Position , Selection , commands } from 'vscode' ; export function returnHighest ( num1 , num2 ) { return num1 > num2 ? num1 : num2 ; } export function returnLowest ( num1 , num2 ) { return num1 < num2 ? num1 : num2 ; } export function oneNumberIsNegative ( num1 , num2 ) { return ( num1 <= - 1 || num2 <= - 1 ) ; } export function getPreviousChar ( currentPosition , text ) { return text . substring ( currentPosition - 1 , currentPosition ) ; } export function getNextChar ( currentPosition , text ) { return text . substring ( currentPosition + 1 , currentPosition ) ; } export function determineNextSpecialCharPosition ( charInfo , text , position ) { let positionNextOpenChar = text . indexOf ( charInfo . open , position + 1 ) ; if ( positionNextOpenChar == - 1 ) { positionNextOpenChar = text . indexOf ( charInfo . close , position + 1 ) ; } if ( positionNextOpenChar == - 1 ) { var strToSearchIn = text . substr ( position ) ; var counter = position ; for ( var char of strToSearchIn ) { counter ++ ; let info = characterSetsToTabOutFrom ( ) . find ( c => c . open == char || c . close == char ) ; if ( info !== undefined ) { positionNextOpenChar = counter ; break ; } } } return positionNextOpenChar ; } export function selectNextCharacter ( text , position ) { let nextCharacter = getNextChar ( position , text ) ; let indxNext = characterSetsToTabOutFrom ( ) . find ( o => o . open == nextCharacter || o . close == nextCharacter ) ; if ( indxNext !== undefined ) { let nextCursorPosition = new Position ( window . activeTextEditor . selection . active . line , position + 1 ) ; return window . activeTextEditor . selection = new Selection ( nextCursorPosition , nextCursorPosition ) ; } commands . executeCommand ( "tab" ) ; }