Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions pkg/gui/controllers/context_lines_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var CONTEXT_KEYS_SHOWING_DIFFS = []types.ContextKey{
context.STAGING_SECONDARY_CONTEXT_KEY,
context.PATCH_BUILDING_MAIN_CONTEXT_KEY,
context.PATCH_BUILDING_SECONDARY_CONTEXT_KEY,
context.NORMAL_MAIN_CONTEXT_KEY,
context.NORMAL_SECONDARY_CONTEXT_KEY,
}

type ContextLinesController struct {
Expand Down Expand Up @@ -97,7 +99,7 @@ func (self *ContextLinesController) applyChange() error {
self.c.Toast(fmt.Sprintf(self.c.Tr.DiffContextSizeChanged, self.c.AppState.DiffContextSize))
self.c.SaveAppStateAndLogError()

currentContext := self.c.Context().CurrentStatic()
currentContext := self.currentSidePanel()
switch currentContext.GetKey() {
// we make an exception for our staging and patch building contexts because they actually need to refresh their state afterwards.
case context.PATCH_BUILDING_MAIN_CONTEXT_KEY:
Expand All @@ -121,6 +123,16 @@ func (self *ContextLinesController) checkCanChangeContext() error {
func (self *ContextLinesController) isShowingDiff() bool {
return lo.Contains(
CONTEXT_KEYS_SHOWING_DIFFS,
self.c.Context().CurrentStatic().GetKey(),
self.currentSidePanel().GetKey(),
)
}

func (self *ContextLinesController) currentSidePanel() types.Context {
currentContext := self.c.Context().CurrentStatic()
if currentContext.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY ||
currentContext.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY {
return currentContext.GetParentContext()
}

return currentContext
}
16 changes: 14 additions & 2 deletions pkg/gui/controllers/rename_similarity_threshold_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var CONTEXT_KEYS_SHOWING_RENAMES = []types.ContextKey{
context.SUB_COMMITS_CONTEXT_KEY,
context.LOCAL_COMMITS_CONTEXT_KEY,
context.STASH_CONTEXT_KEY,
context.NORMAL_MAIN_CONTEXT_KEY,
context.NORMAL_SECONDARY_CONTEXT_KEY,
}

type RenameSimilarityThresholdController struct {
Expand Down Expand Up @@ -82,7 +84,7 @@ func (self *RenameSimilarityThresholdController) applyChange() error {
self.c.Toast(fmt.Sprintf(self.c.Tr.RenameSimilarityThresholdChanged, self.c.AppState.RenameSimilarityThreshold))
self.c.SaveAppStateAndLogError()

currentContext := self.c.Context().CurrentStatic()
currentContext := self.currentSidePanel()
switch currentContext.GetKey() {
// we make an exception for our files context, because it actually need to refresh its state afterwards.
case context.FILES_CONTEXT_KEY:
Expand All @@ -96,6 +98,16 @@ func (self *RenameSimilarityThresholdController) applyChange() error {
func (self *RenameSimilarityThresholdController) isShowingRenames() bool {
return lo.Contains(
CONTEXT_KEYS_SHOWING_RENAMES,
self.c.Context().CurrentStatic().GetKey(),
self.currentSidePanel().GetKey(),
)
}

func (self *RenameSimilarityThresholdController) currentSidePanel() types.Context {
currentContext := self.c.Context().CurrentStatic()
if currentContext.GetKey() == context.NORMAL_MAIN_CONTEXT_KEY ||
currentContext.GetKey() == context.NORMAL_SECONDARY_CONTEXT_KEY {
return currentContext.GetParentContext()
}

return currentContext
}
12 changes: 12 additions & 0 deletions pkg/integration/tests/diff/rename_similarity_threshold_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,17 @@ var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{
Contains("original => renamed"),
Contains("1 file changed, 5 insertions(+)"),
)

t.Views().Commits().
Press(keys.Universal.FocusMainView)

t.Views().Main().
Press(keys.Universal.IncreaseRenameSimilarityThreshold).
Tap(func() {
t.ExpectToast(Equals("Changed rename similarity threshold to 50%"))
}).
ContainsLines(
Contains("2 files changed, 10 insertions(+), 5 deletions(-)"),
)
},
})
11 changes: 11 additions & 0 deletions pkg/integration/tests/file/rename_similarity_threshold_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ var RenameSimilarityThresholdChange = NewIntegrationTest(NewIntegrationTestArgs{
}).
Lines(
Equals("R original → renamed"),
).
Press(keys.Universal.FocusMainView).
Tap(func() {
t.Views().Main().
Press(keys.Universal.IncreaseRenameSimilarityThreshold)
t.ExpectToast(Equals("Changed rename similarity threshold to 50%"))
}).
Lines(
Equals("▼ /"),
Equals(" D original"),
Equals(" A renamed"),
)
},
})