mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert "IDEA-87713 Ctrl + Backspace changed behaviour"
This reverts commit 720ae9faa5.
This commit is contained in:
+4
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -24,15 +24,12 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.actions;
|
||||
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
|
||||
public class DeleteToWordStartAction extends TextComponentEditorAction {
|
||||
public DeleteToWordStartAction() {
|
||||
@@ -48,31 +45,10 @@ public class DeleteToWordStartAction extends TextComponentEditorAction {
|
||||
}
|
||||
|
||||
private static void deleteToWordStart(Editor editor) {
|
||||
final CaretModel caretModel = editor.getCaretModel();
|
||||
int endOffset = caretModel.getOffset();
|
||||
|
||||
// The logic is as follows:
|
||||
// 1. Check are there white-space symbols starting at the current caret position going backwards. Delete them if any;
|
||||
// 2. Otherwise locate previous word start and delete the text up to it;
|
||||
// Example:
|
||||
// 'test string <caret>' -> 'test string<caret>'
|
||||
// 'test string<caret>' -> 'test <caret>'
|
||||
|
||||
int endOffset = editor.getCaretModel().getOffset();
|
||||
EditorActionUtil.moveCaretToPreviousWord(editor, false);
|
||||
int startOffset = editor.getCaretModel().getOffset();
|
||||
Document document = editor.getDocument();
|
||||
final SelectionModel selectionModel = editor.getSelectionModel();
|
||||
int startOffset = -1;
|
||||
if (!selectionModel.hasSelection() && !selectionModel.hasBlockSelection()) {
|
||||
int i = CharArrayUtil.shiftBackward(document.getCharsSequence(), Math.max(0, endOffset - 1), " \t\n");
|
||||
if (i >= 0 && i < endOffset - 1) {
|
||||
startOffset = i + 1; // We need offset of the first white space symbol, not offset of the last non-white space symbol before it.
|
||||
}
|
||||
}
|
||||
|
||||
if (startOffset < 0) {
|
||||
EditorActionUtil.moveCaretToPreviousWord(editor, false);
|
||||
startOffset = caretModel.getOffset();
|
||||
}
|
||||
|
||||
document.deleteString(startOffset, endOffset);
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2011 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.
|
||||
@@ -514,69 +514,69 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
}
|
||||
}
|
||||
protected static void backspace() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_BACKSPACE);
|
||||
doAction(IdeActions.ACTION_EDITOR_BACKSPACE);
|
||||
}
|
||||
protected static void delete() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_DELETE);
|
||||
doAction(IdeActions.ACTION_EDITOR_DELETE);
|
||||
}
|
||||
|
||||
protected static void home() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_MOVE_LINE_START);
|
||||
doAction(IdeActions.ACTION_EDITOR_MOVE_LINE_START);
|
||||
}
|
||||
|
||||
protected static void end() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END);
|
||||
doAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END);
|
||||
}
|
||||
|
||||
protected static void copy() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_COPY);
|
||||
doAction(IdeActions.ACTION_EDITOR_COPY);
|
||||
}
|
||||
|
||||
protected static void paste() {
|
||||
executeAction(IdeActions.ACTION_EDITOR_PASTE);
|
||||
doAction(IdeActions.ACTION_EDITOR_PASTE);
|
||||
}
|
||||
|
||||
protected static void moveCaretToPreviousWordWithSelection() {
|
||||
executeAction("EditorPreviousWordWithSelection");
|
||||
doAction("EditorPreviousWordWithSelection");
|
||||
}
|
||||
|
||||
protected static void moveCaretToNextWordWithSelection() {
|
||||
executeAction("EditorNextWordWithSelection");
|
||||
doAction("EditorNextWordWithSelection");
|
||||
}
|
||||
|
||||
protected static void cutLineBackward() {
|
||||
executeAction("EditorCutLineBackward");
|
||||
doAction("EditorCutLineBackward");
|
||||
}
|
||||
|
||||
protected static void cutToLineEnd() {
|
||||
executeAction("EditorCutLineEnd");
|
||||
doAction("EditorCutLineEnd");
|
||||
}
|
||||
|
||||
protected static void killToWordStart() {
|
||||
executeAction("EditorKillToWordStart");
|
||||
doAction("EditorKillToWordStart");
|
||||
}
|
||||
|
||||
protected static void killToWordEnd() {
|
||||
executeAction("EditorKillToWordEnd");
|
||||
doAction("EditorKillToWordEnd");
|
||||
}
|
||||
|
||||
protected static void killRegion() {
|
||||
executeAction("EditorKillRegion");
|
||||
doAction("EditorKillRegion");
|
||||
}
|
||||
|
||||
protected static void killRingSave() {
|
||||
executeAction("EditorKillRingSave");
|
||||
doAction("EditorKillRingSave");
|
||||
}
|
||||
|
||||
protected static void unindent() {
|
||||
executeAction("EditorUnindentSelection");
|
||||
doAction("EditorUnindentSelection");
|
||||
}
|
||||
|
||||
protected static void lineComment() {
|
||||
new CommentByLineCommentHandler().invoke(getProject(), getEditor(), getFile());
|
||||
}
|
||||
|
||||
protected static void executeAction(@NotNull final String actionId) {
|
||||
private static void doAction(@NotNull final String actionId) {
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2009 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.
|
||||
@@ -198,17 +198,17 @@ public class CharArrayUtil {
|
||||
return shiftForward(new CharArrayCharSequence(buffer), offset, chars);
|
||||
}
|
||||
|
||||
public static int shiftBackward(CharSequence buffer, int offset, String charsToSkip) {
|
||||
public static int shiftBackward(CharSequence buffer, int offset, String chars) {
|
||||
if (offset >= buffer.length()) return offset;
|
||||
|
||||
while (true) {
|
||||
if (offset < 0) break;
|
||||
char c = buffer.charAt(offset);
|
||||
int i;
|
||||
for (i = 0; i < charsToSkip.length(); i++) {
|
||||
if (c == charsToSkip.charAt(i)) break;
|
||||
for (i = 0; i < chars.length(); i++) {
|
||||
if (c == chars.charAt(i)) break;
|
||||
}
|
||||
if (i == charsToSkip.length()) break;
|
||||
if (i == chars.length()) break;
|
||||
offset--;
|
||||
}
|
||||
return offset;
|
||||
|
||||
Reference in New Issue
Block a user