mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-166403 Backspace does not remove indents and new lines in scratch files
This commit is contained in:
+6
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 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.
|
||||
@@ -21,12 +21,12 @@ import com.intellij.formatting.FormattingModel;
|
||||
import com.intellij.formatting.FormattingModelBuilder;
|
||||
import com.intellij.lang.LanguageFormatting;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
@@ -64,7 +64,7 @@ public class SmartIndentingBackspaceHandler extends AbstractIndentingBackspaceHa
|
||||
if (myReplacement == null) {
|
||||
return;
|
||||
}
|
||||
int tabSize = getTabSize(codeStyleFacade, document);
|
||||
int tabSize = codeStyleFacade.getTabSize(file.getFileType());
|
||||
int targetColumn = getWidth(myReplacement, tabSize);
|
||||
int endOffset = CharArrayUtil.shiftForward(charSequence, caretOffset, " \t");
|
||||
LogicalPosition logicalPosition = caretOffset < endOffset ? editor.offsetToLogicalPosition(endOffset) : pos;
|
||||
@@ -112,12 +112,6 @@ public class SmartIndentingBackspaceHandler extends AbstractIndentingBackspaceHa
|
||||
return StringUtil.repeatSymbol(' ', spacing);
|
||||
}
|
||||
|
||||
private static int getTabSize(@NotNull CodeStyleFacade codeStyleFacade, @NotNull Document document) {
|
||||
VirtualFile file = FileDocumentManager.getInstance().getFile(document);
|
||||
FileType fileType = file == null ? null : file.getFileType();
|
||||
return codeStyleFacade.getTabSize(fileType);
|
||||
}
|
||||
|
||||
private static int getWidth(@NotNull String indent, int tabSize) {
|
||||
int width = 0;
|
||||
for (int i = 0; i < indent.length(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user