public static int getTabAdjustedLength(@Nonnull String text, int tabWidth) {
		int tabIndex = text.indexOf('\t');
		while (tabIndex >= 0) {
			if (tabIndex == 0) {
				text = " ".repeat(tabWidth) + text.substring(1);
			} else {
				// Assuming tab width is four: Having two spaces then a tab still yields a length of 4 visually
				// Thus, we must consider such alignment in our length adjustments.
				String pre = text.substring(0, tabIndex);
				String post = text.substring(tabIndex + 1);
				int alignedLengthExtra = tabWidth - (tabIndex % tabWidth);
				text = pre + " ".repeat(alignedLengthExtra) + post;
			}
			tabIndex = text.indexOf('\t');
		}
		return text.length();
	}
@param text
		Text to compute length of.
@param tabWidth
		Tab width.

@return Length of text, considering tabs.
recaf-core/src/main/java/software/coley/recaf/util/StringUtil.java