RIDER-131949 perform typing on the frontend to fix wrap on typing when limit is exceeded

(cherry picked from commit 506d38464fdf531af039d0d89b4ce155f0c17659)

IJ-MR-181537

GitOrigin-RevId: 8aca1989aed95329916d583b61fe09a79f00c116
This commit is contained in:
Ivan.Yarkov
2025-11-12 20:15:54 +00:00
committed by intellij-monorepo-bot
parent c54da50a6b
commit 2d5ea84239
4 changed files with 13 additions and 10 deletions
@@ -2611,11 +2611,6 @@ f:com.intellij.codeInsight.documentation.QuickDocUtil
- s:inferLinkFromFullDocumentation(com.intellij.lang.documentation.DocumentationProvider,com.intellij.psi.PsiElement,com.intellij.psi.PsiElement,java.lang.String):java.lang.String
- s:updateQuickDoc(com.intellij.openapi.project.Project,com.intellij.psi.PsiElement,java.lang.String):V
- s:updateQuickDocAsync(com.intellij.psi.PsiElement,java.lang.CharSequence,com.intellij.util.Consumer):V
f:com.intellij.codeInsight.editorActions.AutoHardWrapHandler
- sf:AUTO_WRAP_LINE_IN_PROGRESS_KEY:com.intellij.openapi.util.Key
- <init>():V
- s:getInstance():com.intellij.codeInsight.editorActions.AutoHardWrapHandler
- wrapLineIfNecessary(com.intellij.openapi.editor.Editor,com.intellij.openapi.actionSystem.DataContext,J):V
c:com.intellij.codeInsight.editorActions.BackspaceHandler
- com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$ForEachCaret
- pf:myOriginalHandler:com.intellij.openapi.editor.actionSystem.EditorActionHandler
+6
View File
@@ -145,6 +145,12 @@ com.intellij.codeInsight.documentation.DocumentationActionProvider
- sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName
- additionalActions(com.intellij.codeInsight.documentation.DocumentationComponent):java.util.List
- additionalActions(com.intellij.openapi.editor.Editor,com.intellij.psi.PsiDocCommentBase,java.lang.String):java.util.List
c:com.intellij.codeInsight.editorActions.AutoHardWrapHandler
- sf:AUTO_WRAP_LINE_IN_PROGRESS_KEY:com.intellij.openapi.util.Key
- <init>():V
- s:getInstance():com.intellij.codeInsight.editorActions.AutoHardWrapHandler
- p:preprocessLineWrap(com.intellij.openapi.editor.Editor):V
- wrapLineIfNecessary(com.intellij.openapi.editor.Editor,com.intellij.openapi.actionSystem.DataContext,J):V
com.intellij.codeInsight.editorActions.CodeBlockProvider
- a:getCodeBlockRange(com.intellij.openapi.editor.Editor,com.intellij.psi.PsiFile):com.intellij.openapi.util.TextRange
com.intellij.codeInsight.editorActions.CommentCompleteHandler
@@ -7,6 +7,7 @@ import com.intellij.ide.DataManager;
import com.intellij.lang.Language;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.event.DocumentEvent;
@@ -26,7 +27,7 @@ import java.util.WeakHashMap;
/**
* Encapsulates logic for processing {@link EditorSettings#isWrapWhenTypingReachesRightMargin(Project)} option.
*/
public final class AutoHardWrapHandler {
public class AutoHardWrapHandler {
/**
* This key is used as a flag that indicates if {@code 'auto wrap line on typing'} activity is performed now.
@@ -35,8 +36,6 @@ public final class AutoHardWrapHandler {
*/
public static final Key<Boolean> AUTO_WRAP_LINE_IN_PROGRESS_KEY = new Key<>("AUTO_WRAP_LINE_IN_PROGRESS");
private static final AutoHardWrapHandler INSTANCE = new AutoHardWrapHandler();
/**
* There is a possible case that the user configured editor to
* {@link EditorSettings#isWrapWhenTypingReachesRightMargin(Project) wrap line on reaching right margin} and that he or she
@@ -50,7 +49,7 @@ public final class AutoHardWrapHandler {
private final Map<Document, AutoWrapChange> myAutoWrapChanges = new WeakHashMap<>();
public static AutoHardWrapHandler getInstance() {
return INSTANCE;
return ApplicationManager.getApplication().getService(AutoHardWrapHandler.class);
}
/**
@@ -181,7 +180,7 @@ public final class AutoHardWrapHandler {
return event.getNewLength() <= event.getOldLength() && endsWithSpaces;
}
};
preprocessLineWrap(editor);
caretModel.moveToOffset(wrapOffset);
DataManager.getInstance().saveInDataContext(dataContext, AUTO_WRAP_LINE_IN_PROGRESS_KEY, true);
document.addDocumentListener(listener);
@@ -202,6 +201,8 @@ public final class AutoHardWrapHandler {
caretModel.moveToOffset(baseCaretOffset + caretOffsetDiff[0]);
}
protected void preprocessLineWrap(@NotNull Editor editor) {}
private static final class AutoWrapChange {
final TextChangeImpl change = new TextChangeImpl("", 0, 0);
@@ -363,6 +363,7 @@
<projectService serviceImplementation="com.intellij.codeInsight.codeVision.CodeVisionContextProvider"/>
<projectService serviceImplementation="com.intellij.codeInsight.codeVision.ui.model.ProjectCodeVisionModel"/>
<applicationService serviceImplementation="com.intellij.codeInsight.codeVision.ui.renderers.painters.CodeVisionThemeInfoProvider"/>
<applicationService serviceImplementation="com.intellij.codeInsight.editorActions.AutoHardWrapHandler"/>
<registryKey description="Enable Code Vision performance watcher" key="code.vision.performance.watcher.enabled" defaultValue="true"/>
<projectService serviceImplementation="com.intellij.codeInsight.actions.AsyncActionExecutionService"/>