diff --git a/src/main/java/com/zhongan/devpilot/actions/editor/inlay/ChatShortcutHintCollector.java b/src/main/java/com/zhongan/devpilot/actions/editor/inlay/ChatShortcutHintCollector.java index 6f29482..8a16c8f 100644 --- a/src/main/java/com/zhongan/devpilot/actions/editor/inlay/ChatShortcutHintCollector.java +++ b/src/main/java/com/zhongan/devpilot/actions/editor/inlay/ChatShortcutHintCollector.java @@ -120,18 +120,15 @@ private void groupRenderPopupPresentation(InlayHintsSink inlayHintsSink, PsiElem int offset = getAnchorOffset(psiElement); int line = document.getLineNumber(offset); int startOffset = document.getLineStartOffset(line); - InlayPresentation finalPresentation = createPopupPresentation(factory, editor, psiElement, startOffset, offset); inlayHintsSink.addBlockElement(startOffset, true, true, 300, finalPresentation); } private InlayPresentation createPopupPresentation(PresentationFactory factory, Editor editor, PsiElement psiElement, int startOffset, int offset) { - String linePrefix = editor.getDocument().getText(new TextRange(startOffset, offset)); - int column = offset - startOffset + findOffsetBySpace(editor, linePrefix); - + int gap = computeInitialWhitespace(editor, psiElement); List presentations = new SmartList<>(); - presentations.add(factory.textSpacePlaceholder(column, true)); + presentations.add(factory.textSpacePlaceholder(gap, true)); presentations.add(factory.smallScaledIcon(DevPilotIcons.SYSTEM_ICON_INLAY)); presentations.add(factory.smallScaledIcon(AllIcons.Actions.FindAndShowNextMatchesSmall)); presentations.add(factory.textSpacePlaceholder(1, true)); @@ -210,18 +207,6 @@ private static int getAnchorOffset(@NotNull PsiElement psiElement) { return anchorOffset; } - private int findOffsetBySpace(@NotNull Editor editor, String linePrefix) { - int tabWidth = editor.getSettings().getTabSize(editor.getProject()); - int totalOffset = 0; - - for (int i = 0; i < linePrefix.length(); ++i) { - if (linePrefix.charAt(i) == '\t') { - totalOffset += tabWidth; - } - } - return totalOffset; - } - private int computeInitialWhitespace(Editor editor, PsiElement psiElement) { int lineNum = editor.getDocument().getLineNumber(psiElement.getTextRange().getStartOffset()); String textOnLine = editor.getDocument().getText(new TextRange(editor.getDocument().getLineStartOffset(lineNum),