Skip to content

Commit 15288b7

Browse files
committed
Add user config to enable line wrapping in the staging view
It is enabled by default, because I think it's often helpful, and rarely in the way. I bet most user won't even notice.
1 parent 2828fb9 commit 15288b7

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

docs/Config.md

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ gui:
8787
# - 'top': split the window vertically (side panel on top, main view below)
8888
enlargedSideViewLocation: left
8989

90+
# If true, wrap lines in the staging view to the width of the view. This
91+
# makes it much easier to work with diffs that have long lines, e.g.
92+
# paragraphs of markdown text.
93+
wrapLinesInStagingView: true
94+
9095
# One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru'
9196
language: auto
9297

pkg/config/user_config.go

+5
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ type GuiConfig struct {
9191
// - 'left': split the window horizontally (side panel on the left, main view on the right)
9292
// - 'top': split the window vertically (side panel on top, main view below)
9393
EnlargedSideViewLocation string `yaml:"enlargedSideViewLocation"`
94+
// If true, wrap lines in the staging view to the width of the view. This
95+
// makes it much easier to work with diffs that have long lines, e.g.
96+
// paragraphs of markdown text.
97+
WrapLinesInStagingView bool `yaml:"wrapLinesInStagingView"`
9498
// One of 'auto' (default) | 'en' | 'zh-CN' | 'zh-TW' | 'pl' | 'nl' | 'ja' | 'ko' | 'ru'
9599
Language string `yaml:"language" jsonschema:"enum=auto,enum=en,enum=zh-TW,enum=zh-CN,enum=pl,enum=nl,enum=ja,enum=ko,enum=ru"`
96100
// Format used when displaying time e.g. commit time.
@@ -692,6 +696,7 @@ func GetDefaultConfig() *UserConfig {
692696
ExpandedSidePanelWeight: 2,
693697
MainPanelSplitMode: "flexible",
694698
EnlargedSideViewLocation: "left",
699+
WrapLinesInStagingView: true,
695700
Language: "auto",
696701
TimeFormat: "02 Jan 06",
697702
ShortTimeFormat: time.Kitchen,

pkg/gui/controllers/patch_building_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (self *PatchBuildingController) GetMouseKeybindings(opts types.KeybindingsO
6565
func (self *PatchBuildingController) GetOnFocus() func(types.OnFocusOpts) {
6666
return func(opts types.OnFocusOpts) {
6767
// no need to change wrap on the secondary view because it can't be interacted with
68-
self.c.Views().PatchBuilding.Wrap = false
68+
self.c.Views().PatchBuilding.Wrap = self.c.UserConfig().Gui.WrapLinesInStagingView
6969

7070
self.c.Helpers().PatchBuilding.RefreshPatchBuildingPanel(opts)
7171
}

pkg/gui/controllers/staging_controller.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ func (self *StagingController) GetMouseKeybindings(opts types.KeybindingsOpts) [
118118

119119
func (self *StagingController) GetOnFocus() func(types.OnFocusOpts) {
120120
return func(opts types.OnFocusOpts) {
121-
self.c.Views().Staging.Wrap = false
122-
self.c.Views().StagingSecondary.Wrap = false
121+
wrap := self.c.UserConfig().Gui.WrapLinesInStagingView
122+
self.c.Views().Staging.Wrap = wrap
123+
self.c.Views().StagingSecondary.Wrap = wrap
123124

124125
self.c.Helpers().Staging.RefreshStagingPanel(opts)
125126
}

schema/config.json

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@
9696
"description": "How the window is split when in half screen mode (i.e. after hitting '+' once).\nPossible values:\n- 'left': split the window horizontally (side panel on the left, main view on the right)\n- 'top': split the window vertically (side panel on top, main view below)",
9797
"default": "left"
9898
},
99+
"wrapLinesInStagingView": {
100+
"type": "boolean",
101+
"description": "If true, wrap lines in the staging view to the width of the view. This\nmakes it much easier to work with diffs that have long lines, e.g.\nparagraphs of markdown text.",
102+
"default": true
103+
},
99104
"language": {
100105
"type": "string",
101106
"enum": [

0 commit comments

Comments
 (0)