mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-85624 <Delete> doesn't work correctly for wrapped commit comment
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -106,7 +106,10 @@ public class DeleteAction extends EditorAction {
|
||||
Document document = editor.getDocument();
|
||||
int offset = editor.getCaretModel().getOffset();
|
||||
if (!EditorActionUtil.canEditAtOffset(editor, offset + 1)) return;
|
||||
if (afterLineEnd < 0) {
|
||||
if (afterLineEnd < 0
|
||||
// There is a possible case that caret is located right before the soft wrap position at the last logical line
|
||||
// (popular use case with the soft wraps at the commit message dialog).
|
||||
|| (offset < document.getTextLength() - 1 && editor.getSoftWrapModel().getSoftWrap(offset) != null)) {
|
||||
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(offset);
|
||||
if (region != null && region.shouldNeverExpand()) {
|
||||
document.deleteString(region.getStartOffset(), region.getEndOffset());
|
||||
|
||||
+16
@@ -952,6 +952,22 @@ public class SoftWrapApplianceOnDocumentModificationTest extends AbstractEditorP
|
||||
checkSoftWraps(start, end);
|
||||
assertEquals(new VisualPosition(3, 0), myEditor.offsetToVisualPosition(text.indexOf("second")));
|
||||
}
|
||||
|
||||
public void testDeleteWhenCaretBeforeSoftWrap() throws IOException {
|
||||
final String text =
|
||||
"text 1234";
|
||||
init(7, text);
|
||||
|
||||
final int offset = text.indexOf("123");
|
||||
checkSoftWraps(offset);
|
||||
|
||||
final CaretModel caretModel = myEditor.getCaretModel();
|
||||
caretModel.moveToOffset(offset);
|
||||
caretModel.moveCaretRelatively(-1, 0, false, false, false);
|
||||
assertEquals(offset, caretModel.getOffset()); // Navigating from 'after soft wrap' to the 'before soft wrap' position.
|
||||
delete();
|
||||
assertEquals("text 234", myEditor.getDocument().getText());
|
||||
}
|
||||
|
||||
private void init(final int visibleWidthInColumns, @NotNull String fileText) throws IOException {
|
||||
int symbolWidthInPixels = 7;
|
||||
|
||||
Reference in New Issue
Block a user