Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
Forcing reinitSettings when CodeStyleSettings are applied so that tab…
Browse files Browse the repository at this point in the history
…width will be correct, incremented version to 0.1.3
  • Loading branch information
bellkev committed Aug 4, 2013
1 parent fcd81b2 commit 38fad2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin version="2">
<id>org.editorconfig.editorconfigjetbrains</id>
<name>EditorConfig</name>
<version>0.1.2</version>
<version>0.1.3</version>
<vendor email="[email protected]" url="http://editorconfig.org">Kevin Bell</vendor>

<description><![CDATA[
Expand Down
39 changes: 23 additions & 16 deletions src/org/editorconfig/configmanagement/CodeStyleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.EditorEx;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
Expand Down Expand Up @@ -71,22 +72,28 @@ public void windowLostFocus(WindowEvent e) {
}

private void applySettings(VirtualFile file) {
// Always drop any current temporary settings so that the defaults will be applied if
// this is a non-editorconfig-managed file
codeStyleSettingsManager.dropTemporarySettings();
// Prepare a new settings object, which will maintain the standard settings if no
// editorconfig settings apply
CodeStyleSettings currentSettings = codeStyleSettingsManager.getCurrentSettings();
CodeStyleSettings newSettings = new CodeStyleSettings();
newSettings.copyFrom(currentSettings);
// Get editorconfig settings
String filePath = file.getCanonicalPath();
SettingsProviderComponent settingsProvider = SettingsProviderComponent.getInstance();
List<OutPair> outPairs = settingsProvider.getOutPairs(filePath);
// Apply editorconfig settings for the current editor
applyCodeStyleSettings(outPairs, newSettings, filePath);
codeStyleSettingsManager.setTemporarySettings(newSettings);
LOG.debug("Applied code style settings for: " + filePath);
if (file != null) {
// Always drop any current temporary settings so that the defaults will be applied if
// this is a non-editorconfig-managed file
codeStyleSettingsManager.dropTemporarySettings();
// Prepare a new settings object, which will maintain the standard settings if no
// editorconfig settings apply
CodeStyleSettings currentSettings = codeStyleSettingsManager.getCurrentSettings();
CodeStyleSettings newSettings = new CodeStyleSettings();
newSettings.copyFrom(currentSettings);
// Get editorconfig settings
String filePath = file.getCanonicalPath();
SettingsProviderComponent settingsProvider = SettingsProviderComponent.getInstance();
List<OutPair> outPairs = settingsProvider.getOutPairs(filePath);
// Apply editorconfig settings for the current editor
applyCodeStyleSettings(outPairs, newSettings, filePath);
codeStyleSettingsManager.setTemporarySettings(newSettings);
LOG.debug("Applied code style settings for: " + filePath);
EditorEx currentEditor = (EditorEx) FileEditorManager.getInstance(project).getSelectedTextEditor();
if (currentEditor != null){
currentEditor.reinitSettings();
}
}
}

private void applyCodeStyleSettings(List<OutPair> outPairs,
Expand Down

0 comments on commit 38fad2d

Please sign in to comment.