New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comment block disappears #505
Comments
Can you please provide a small example of yaml - I can't make sense of this |
background_opacity: 0.6
key_bindings:
# (Windows/Linux only)
#- { key: V, mods: Control|Shift, action: Paste }
#- { key: C, mods: Control|Shift, action: Copy }
#- { key: Insert, mods: Shift, action: PasteSelection }
#- { key: Key0, mods: Control, action: ResetFontSize }
#- { key: Equals, mods: Control, action: IncreaseFontSize }
#- { key: Add, mods: Control, action: IncreaseFontSize }
#- { key: Subtract, mods: Control, action: DecreaseFontSize }
#- { key: Minus, mods: Control, action: DecreaseFontSize }
#- { key: Return, mods: Alt, action: ToggleFullscreen }
# (macOS only)
#- { key: Key0, mods: Command, action: ResetFontSize }
#- { key: Equals, mods: Command, action: IncreaseFontSize }
#- { key: Add, mods: Command, action: IncreaseFontSize }
#- { key: Minus, mods: Command, action: DecreaseFontSize }
#- { key: K, mods: Command, action: ClearHistory }
#- { key: K, mods: Command, chars: "\x0c" }
#- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy }
#- { key: H, mods: Command, action: Hide }
#- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit }
#- { key: F, mods: Command|Control, action: ToggleFullscreen }
- { key: Paste, action: Paste }
- { key: Copy, action: Copy }
- { key: L, mods: Control, action: ClearLogNotice }
- { key: L, mods: Control, chars: "\x0c" } Command to run: yq w -i ~/.config/alacritty/alacritty.yml background_opacity 1 Expected: only modify Actual: It deleted comments unexpectedly: background_opacity: 1
key_bindings:
# (macOS only)
#- { key: Key0, mods: Command, action: ResetFontSize }
#- { key: Equals, mods: Command, action: IncreaseFontSize }
#- { key: Add, mods: Command, action: IncreaseFontSize }
#- { key: Minus, mods: Command, action: DecreaseFontSize }
#- { key: K, mods: Command, action: ClearHistory }
#- { key: K, mods: Command, chars: "\x0c" }
#- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy }
#- { key: H, mods: Command, action: Hide }
#- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit }
#- { key: F, mods: Command|Control, action: ToggleFullscreen }
- {key: Paste, action: Paste}
- {key: Copy, action: Copy}
- {key: L, mods: Control, action: ClearLogNotice}
- {key: L, mods: Control, chars: "\f"} |
Played around with this, looks likes its an issue with the underlying yaml parser: |
Note - as a (hacky) workaround if you remove or replace the empty line before key_binding, or the the empty line before the macOS comment - it seems to work. You could replace the empty line with an empty comment instead. |
@mikefarah thanks for the tip, removing empty lines prevented them from being removed |
Fixed in 4.3.0 |
Describe the bug
Inplace writing is deleting comment blocks
version of yq:
3.3.2
operating system:
Linux archlinux 5.4.36-1-lts #1 SMP Wed, 29 Apr 2020 16:23:03 +0000 x86_64 GNU/Linux
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug)
data1.yml:
(Removed by Mike - too long)
The text was updated successfully, but these errors were encountered: