diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3a6c95bc..6449cd85b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
## [Unreleased]
### Added
+* Add option to disable automatic compilation in power save mode
+* Convert automatic compilation settings to a combobox
* Add checkboxes to graphic insertion wizard for relative width or height
### Fixed
@@ -10,7 +12,6 @@
## [0.9.10-alpha.4] - 2024-12-21
### Added
-
* Add sections to breadcrumbs
* Improve performance when starting a run configuration and when using autocompletion directly after starting the IDE
* Change order in structure view to match source file and sectioning level
diff --git a/Writerside/topics/Running-a-LaTeX-file.md b/Writerside/topics/Running-a-LaTeX-file.md
index 42c40c4b1..2c4fcce80 100644
--- a/Writerside/topics/Running-a-LaTeX-file.md
+++ b/Writerside/topics/Running-a-LaTeX-file.md
@@ -86,12 +86,17 @@ Currently the automatic compilation is only triggered when you type in a documen
![autocompile](autocompile.gif)
-## Automatic compilation only when the document is saved.
+### Automatic compilation only when the document is saved.
You can enable this in TeXiFy settings.
When enabled, auto compilation will only run when the file is actually saved to disk, instead of after every change.
To configure when a file is saved to disk (for example after a certain idle time), go to Settings | Appearance | System Settings.
Also see [https://www.jetbrains.com/help/idea/saving-and-reverting-changes.html](https://www.jetbrains.com/help/idea/saving-and-reverting-changes.html)
+### Disable automatic compilation in power save mode
+
+If you select this option, automatic compilation will always be on, except when power save mode is enabled, which can be done via File | Power Save Mode.
+There are various other plugins which can automatically enable power save mode in certain situations.
+
### Automatic compilation support by compilers
Some compilers, at least latexmk and tectonic, also support automatic compilation.
diff --git a/Writerside/topics/TeXiFy-settings.md b/Writerside/topics/TeXiFy-settings.md
index 1961ac831..abb299c0b 100644
--- a/Writerside/topics/TeXiFy-settings.md
+++ b/Writerside/topics/TeXiFy-settings.md
@@ -57,11 +57,6 @@ If you disable this, consider if TeXiFy should support your use case and please
By default, when using a remote library (see [Tool Windows](Tool-Windows.md#remote-libraries)), any entries that you select in autocompletion will be copied to the local BibTeX file.
This settings disables that, which can be useful if you are including BibTeX files in a way that cannot be parsed by TeXiFy.
-## Option to enable automatic compilation
-_Since b0.6.8_
-
-See [Support for automatic compilation](Running-a-LaTeX-file.md#automatic-compilation).
-
## Option to enable continuous preview of math and TikZ environments
_Since b0.6.7_
@@ -142,6 +137,11 @@ For more advantages, see [https://tex.stackexchange.com/questions/39285/whats-th
Choose what method to use to convert HTML to LaTeX when pasting from clipboard, see [Tools](Tools.md#paste-html-into-latex)
+## Options for automatic compilation
+_Since b0.6.8_
+
+See [Support for automatic compilation](Running-a-LaTeX-file.md#automatic-compilation).
+
## Conventions
These settings can be found in File | Settings | Languages & Frameworks | TeXiFy | Conventions and allow you to configure Latex code conventions that apply either globally or for the current project.
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileDoneListener.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileDoneListener.kt
index 787d0c0d3..788665b3b 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileDoneListener.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileDoneListener.kt
@@ -11,8 +11,8 @@ import nl.hannahsten.texifyidea.settings.TexifySettings
class AutoCompileDoneListener : ProcessListener {
override fun processTerminated(event: ProcessEvent) {
- if (TexifySettings.getInstance().autoCompile) {
- AutoCompileState.compileDone()
+ if (TexifySettings.getInstance().isAutoCompileEnabled()) {
+ AutoCompileState.scheduleCompilationIfNecessary()
}
}
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
index 16cae75e9..bc196e121 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileHandler.kt
@@ -17,7 +17,7 @@ class AutocompileHandler : TypedHandlerDelegate() {
override fun charTyped(char: Char, project: Project, editor: Editor, file: PsiFile): Result {
run {
// Only do this for latex files and if the option is enabled
- if (file.fileType != LatexFileType || !TexifySettings.getInstance().autoCompile || TexifySettings.getInstance().autoCompileOnSaveOnly) {
+ if (file.fileType != LatexFileType || !TexifySettings.getInstance().isAutoCompileEnabled()) {
return@run
}
@@ -32,7 +32,7 @@ class AutoCompileBackspacehandler : BackspaceHandlerDelegate() {
override fun beforeCharDeleted(c: Char, file: PsiFile, editor: Editor) {
val project = editor.project
- if (file.isLatexFile() && project != null && TexifySettings.getInstance().autoCompile && !TexifySettings.getInstance().autoCompileOnSaveOnly) {
+ if (file.isLatexFile() && project != null && TexifySettings.getInstance().isAutoCompileEnabled()) {
AutoCompileState.documentChanged(project)
}
}
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileState.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileState.kt
index 1bff7f915..7da53a8a8 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileState.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileState.kt
@@ -45,7 +45,7 @@ object AutoCompileState {
* Tell the state a compilation has just finished.
*/
@Synchronized
- fun compileDone() {
+ fun scheduleCompilationIfNecessary() {
// Only compile again if needed
if (hasChanged) {
scheduleCompilation()
diff --git a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileVfsListener.kt b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileVfsListener.kt
index c25f3e37f..ba9b62754 100644
--- a/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileVfsListener.kt
+++ b/src/nl/hannahsten/texifyidea/editor/autocompile/AutoCompileVfsListener.kt
@@ -17,7 +17,7 @@ import nl.hannahsten.texifyidea.settings.TexifySettings
class AutoCompileVfsListener : AsyncFileListener {
override fun prepareChange(events: MutableList): ChangeApplier? {
- if (!TexifySettings.getInstance().autoCompileOnSaveOnly || !events.any { it.file?.fileType == LatexFileType }) return null
+ if (TexifySettings.getInstance().autoCompileOption != TexifySettings.AutoCompile.AFTER_DOCUMENT_SAVE || !events.any { it.file?.fileType == LatexFileType }) return null
return object : ChangeApplier {
override fun afterVfsChange() {
super.afterVfsChange()
diff --git a/src/nl/hannahsten/texifyidea/settings/TexifyConfigurable.kt b/src/nl/hannahsten/texifyidea/settings/TexifyConfigurable.kt
index 47c032b26..613b8543c 100644
--- a/src/nl/hannahsten/texifyidea/settings/TexifyConfigurable.kt
+++ b/src/nl/hannahsten/texifyidea/settings/TexifyConfigurable.kt
@@ -24,8 +24,6 @@ class TexifyConfigurable : SearchableConfigurable {
private var automaticItemInItemize: JBCheckBox? = null
private var automaticDependencyCheck: JBCheckBox? = null
private var automaticBibtexImport: JBCheckBox? = null
- private var autoCompile: JBCheckBox? = null
- private var autoCompileOnSaveOnly: JBCheckBox? = null
private var continuousPreview: JBCheckBox? = null
private var includeBackslashInSelection: JBCheckBox? = null
private var showPackagesInStructureView: JBCheckBox? = null
@@ -35,6 +33,7 @@ class TexifyConfigurable : SearchableConfigurable {
private var latexIndentOptions: RawCommandLineEditor? = null
private var automaticQuoteReplacement: ComboBox? = null
private var htmlPasteTranslator: ComboBox? = null
+ private var autoCompileOption: ComboBox? = null
/**
* Map UI variables to underlying setting variables
@@ -45,8 +44,6 @@ class TexifyConfigurable : SearchableConfigurable {
Pair(::automaticItemInItemize, settings::automaticItemInItemize),
Pair(::automaticDependencyCheck, settings::automaticDependencyCheck),
Pair(::automaticBibtexImport, settings::automaticBibtexImport),
- Pair(::autoCompile, settings::autoCompile),
- Pair(::autoCompileOnSaveOnly, settings::autoCompileOnSaveOnly),
Pair(::continuousPreview, settings::continuousPreview),
Pair(::includeBackslashInSelection, settings::includeBackslashInSelection),
Pair(::showPackagesInStructureView, settings::showPackagesInStructureView),
@@ -69,8 +66,6 @@ class TexifyConfigurable : SearchableConfigurable {
automaticItemInItemize = addCheckbox("Automatically insert '\\item' in itemize-like environments on pressing enter")
automaticDependencyCheck = addCheckbox("Automatically check for required package dependencies and insert them")
automaticBibtexImport = addCheckbox("Automatically copy BibTeX entries from remote libraries to the local library")
- autoCompile = addCheckbox("Automatic compilation (warning: can cause high CPU usage)")
- autoCompileOnSaveOnly = addCheckbox("Automatic compilation only after document save")
continuousPreview = addCheckbox("Automatically refresh preview of math and TikZ pictures")
includeBackslashInSelection = addCheckbox("Include the backslash in the selection when selecting a LaTeX command")
showPackagesInStructureView = addCheckbox("Show LaTeX package files in structure view (warning: structure view will take more time to load)")
@@ -80,6 +75,7 @@ class TexifyConfigurable : SearchableConfigurable {
latexIndentOptions = addCommandLineEditor("Latexindent", TexifySettingsState().latexIndentOptions)
automaticQuoteReplacement = addComboBox("Smart quote substitution: ", "Off", "TeX ligatures", "TeX commands", "csquotes")
htmlPasteTranslator = addComboBox("HTML paste translator", "Built-in", "Pandoc", "Disabled")
+ autoCompileOption = addComboBox("Automatic compilation", "Off", "Always", "After document save", "Disable in power save mode")
}
)
}
@@ -138,7 +134,8 @@ class TexifyConfigurable : SearchableConfigurable {
textidoteOptions?.text != settings.textidoteOptions ||
latexIndentOptions?.text != settings.latexIndentOptions ||
automaticQuoteReplacement?.selectedIndex != settings.automaticQuoteReplacement.ordinal ||
- htmlPasteTranslator?.selectedIndex != settings.htmlPasteTranslator.ordinal
+ htmlPasteTranslator?.selectedIndex != settings.htmlPasteTranslator.ordinal ||
+ autoCompileOption?.selectedIndex != settings.autoCompileOption.ordinal
}
override fun apply() {
@@ -149,6 +146,7 @@ class TexifyConfigurable : SearchableConfigurable {
settings.latexIndentOptions = latexIndentOptions?.text ?: ""
settings.automaticQuoteReplacement = TexifySettings.QuoteReplacement.entries.toTypedArray()[automaticQuoteReplacement?.selectedIndex ?: 0]
settings.htmlPasteTranslator = TexifySettings.HtmlPasteTranslator.entries.toTypedArray()[htmlPasteTranslator?.selectedIndex ?: 0]
+ settings.autoCompileOption = TexifySettings.AutoCompile.entries.toTypedArray()[autoCompileOption?.selectedIndex ?: 0]
}
override fun reset() {
@@ -159,5 +157,6 @@ class TexifyConfigurable : SearchableConfigurable {
latexIndentOptions?.text = settings.latexIndentOptions
automaticQuoteReplacement?.selectedIndex = settings.automaticQuoteReplacement.ordinal
htmlPasteTranslator?.selectedIndex = settings.htmlPasteTranslator.ordinal
+ autoCompileOption?.selectedIndex = settings.autoCompileOption.ordinal
}
}
diff --git a/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt b/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
index a1114fe11..4632a0762 100644
--- a/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
+++ b/src/nl/hannahsten/texifyidea/settings/TexifySettings.kt
@@ -1,5 +1,6 @@
package nl.hannahsten.texifyidea.settings
+import com.intellij.ide.PowerSaveMode
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.RoamingType
@@ -38,13 +39,18 @@ class TexifySettings : PersistentStateComponent {
DISABLED,
}
+ enum class AutoCompile {
+ OFF,
+ ALWAYS,
+ AFTER_DOCUMENT_SAVE,
+ DISABLE_ON_POWER_SAVE,
+ }
+
var automaticSecondInlineMathSymbol = true
var automaticUpDownBracket = true
var automaticItemInItemize = true
var automaticDependencyCheck = true
var automaticBibtexImport = true
- var autoCompile = false
- var autoCompileOnSaveOnly = false
var continuousPreview = false
var includeBackslashInSelection = false
var showPackagesInStructureView = false
@@ -54,6 +60,7 @@ class TexifySettings : PersistentStateComponent {
var latexIndentOptions = ""
var automaticQuoteReplacement = QuoteReplacement.NONE
var htmlPasteTranslator = HtmlPasteTranslator.BUILTIN
+ var autoCompileOption = AutoCompile.OFF
/**
* Backwards compatibility. This value is never altered, only read from/to memory.
@@ -70,8 +77,6 @@ class TexifySettings : PersistentStateComponent {
automaticItemInItemize = automaticItemInItemize,
automaticDependencyCheck = automaticDependencyCheck,
automaticBibtexImport = automaticBibtexImport,
- autoCompile = autoCompile,
- autoCompileOnSaveOnly = autoCompileOnSaveOnly,
continuousPreview = continuousPreview,
includeBackslashInSelection = includeBackslashInSelection,
showPackagesInStructureView = showPackagesInStructureView,
@@ -81,6 +86,7 @@ class TexifySettings : PersistentStateComponent {
latexIndentOptions = latexIndentOptions,
automaticQuoteReplacement = automaticQuoteReplacement,
htmlPasteTranslator = htmlPasteTranslator,
+ autoCompileOption = autoCompileOption,
pdfViewer = pdfViewer
)
}
@@ -91,8 +97,6 @@ class TexifySettings : PersistentStateComponent {
automaticItemInItemize = state.automaticItemInItemize
automaticDependencyCheck = state.automaticDependencyCheck
automaticBibtexImport = state.automaticBibtexImport
- autoCompile = state.autoCompile
- autoCompileOnSaveOnly = state.autoCompileOnSaveOnly
continuousPreview = state.continuousPreview
includeBackslashInSelection = state.includeBackslashInSelection
showPackagesInStructureView = state.showPackagesInStructureView
@@ -102,6 +106,12 @@ class TexifySettings : PersistentStateComponent {
latexIndentOptions = state.latexIndentOptions
automaticQuoteReplacement = state.automaticQuoteReplacement
htmlPasteTranslator = state.htmlPasteTranslator
+ // Backwards compatibility
+ autoCompileOption = state.autoCompileOption ?: if (state.autoCompileOnSaveOnly) AutoCompile.AFTER_DOCUMENT_SAVE else if (state.autoCompile) AutoCompile.ALWAYS else AutoCompile.OFF
pdfViewer = state.pdfViewer
}
+
+ fun isAutoCompileEnabled(): Boolean {
+ return autoCompileOption == AutoCompile.ALWAYS || (!PowerSaveMode.isEnabled() && autoCompileOption == AutoCompile.DISABLE_ON_POWER_SAVE)
+ }
}
diff --git a/src/nl/hannahsten/texifyidea/settings/TexifySettingsState.kt b/src/nl/hannahsten/texifyidea/settings/TexifySettingsState.kt
index f5756fafc..fdd7c2cc8 100644
--- a/src/nl/hannahsten/texifyidea/settings/TexifySettingsState.kt
+++ b/src/nl/hannahsten/texifyidea/settings/TexifySettingsState.kt
@@ -10,8 +10,6 @@ data class TexifySettingsState(
var automaticItemInItemize: Boolean = true,
var automaticDependencyCheck: Boolean = true,
var automaticBibtexImport: Boolean = true,
- var autoCompile: Boolean = false,
- var autoCompileOnSaveOnly: Boolean = false,
var continuousPreview: Boolean = false,
var includeBackslashInSelection: Boolean = false,
var showPackagesInStructureView: Boolean = false,
@@ -21,6 +19,10 @@ data class TexifySettingsState(
var latexIndentOptions: String = "",
var automaticQuoteReplacement: TexifySettings.QuoteReplacement = TexifySettings.QuoteReplacement.NONE,
var htmlPasteTranslator: TexifySettings.HtmlPasteTranslator = TexifySettings.HtmlPasteTranslator.BUILTIN,
+ var autoCompileOption: TexifySettings.AutoCompile? = null,
var missingLabelMinimumLevel: LatexCommand = LatexGenericRegularCommand.SUBSECTION,
+ // Kept for backwards compatibility
+ var autoCompile: Boolean = false,
+ var autoCompileOnSaveOnly: Boolean = false,
var pdfViewer: InternalPdfViewer = InternalPdfViewer.firstAvailable
)