Skip to content

Commit

Permalink
Merge pull request #79 from SeeSharpSoft/master
Browse files Browse the repository at this point in the history
[FIX] Unwanted focus shifting when "Always Select Opened File" is enabled
  • Loading branch information
SeeSharpSoft authored Sep 17, 2020
2 parents 619f338 + ffe9a3a commit d745226
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Defines the required number of clicks to expand/collapse a node in Project View

If enabled, the expand/collapse states of the folders are kept when a parent folder gets collapsed/expanded.

#### Close preview if no file selected (*enabled*)

Switching the focus in the Project View to an directory or non-displayable element, the preview is closed. Disable to keep the last Preview Editor tab.

Please note: Due to [unwanted side effects](https://github.com/SeeSharpSoft/intellij-file-preview/issues/77), this setting has no effect if **[Always Select Opened File](https://www.jetbrains.com/help/idea/navigating-through-the-source-code.html#scroll_to_from_source)** is enabled.

### Preview Editor Tab

#### Tab title pattern (*<<%s>>*)
Expand All @@ -57,11 +63,7 @@ Defines how the file name is formatted in the preview tab title, while **%s** re

Sets a custom background color for the preview tab.

#### Close tab if no file is selected (*enabled*)

Switching the focus in the Project View to an directory or non-displayable element, the preview is closed. Disable to keep the last Preview Editor tab.

#### Close tab if other tab is selected (*disabled*)
#### Close preview if other tab is selected (*disabled*)

Switching editor tabs does not close the current Preview Editor tab on default.

Expand Down
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'net.seesharpsoft.intellij.plugins'
version '1.6.3'
version '1.6.4'

sourceCompatibility = 1.8

Expand All @@ -29,8 +29,7 @@ intellij {
patchPluginXml {
changeNotes """
<pre style="font-family: sans-serif">
[FIX] Sometimes already opened file is not focused
[FIX] Not removing preview marker on close leads to inconsistent preview & focus behavior
[FIX] Unwanted focus shifting in project view when "Always Select Opened File" is enabled
</pre>
"""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="e13a8" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="e13a8" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand Down Expand Up @@ -68,14 +68,22 @@
<text value="Keep expand/collapse state"/>
</properties>
</component>
<component id="8abe3" class="javax.swing.JCheckBox" binding="cbClosePreviewOnEmptySelection">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Close preview if no file selected, e.g. directory or structure node (NOTE: Implicitely disabled if &quot;Always Select Opened File&quot; is enabled)"/>
</properties>
</component>
</children>
</grid>
<vspacer id="cecf9">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="745d8" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="745d8" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
Expand Down Expand Up @@ -104,25 +112,17 @@
</hspacer>
</children>
</grid>
<component id="8abe3" class="javax.swing.JCheckBox" binding="cbClosePreviewOnEmptySelection">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Close tab if no file is selected (e.g. directory or structure node selected)"/>
</properties>
</component>
<component id="a5105" class="javax.swing.JCheckBox" binding="cbPreviewClosedOnTabChange">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Close tab if other tab is selected"/>
<text value="Close preview if other tab is selected"/>
</properties>
</component>
<component id="e2cc1" class="javax.swing.JCheckBox" binding="cbOpenEditorOnEditPreview">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Convert to standard editor tab when editing previewed file"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static boolean isProjectTreeFocused(@NotNull final Project project) {

private static void openPreviewOrEditor(@NotNull final Project project, final VirtualFile file, final boolean requestFocus) {
if (!isValid(project) || file == null || file.isDirectory() || !file.isValid()) {
if (PreviewSettings.getInstance().isPreviewClosedOnEmptySelection()) {
if (PreviewSettings.getInstance().isPreviewClosedOnEmptySelection() && !isAutoScrollFromSource(project)) {
closeOtherPreviews(project, file);
}
return;
Expand Down

0 comments on commit d745226

Please sign in to comment.