kitten @ resize-window: Fix --increment=0 treated as --increment=2

This commit is contained in:
Kovid Goyal
2024-07-15 22:32:29 +05:30
parent 04735eb072
commit 15dd95d420
2 changed files with 5 additions and 2 deletions

View File

@@ -324,13 +324,16 @@ class JSONField:
self.required = False
self.field, self.field_type = field_def.split('/', 1)
self.field_type, self.special_parser = self.field_type.partition('=')[::2]
self.field_type, self.metadata = self.field_type.partition('-')[::2]
if self.field.endswith('+'):
self.required = True
self.field = self.field[:-1]
self.struct_field_name = self.field[0].upper() + self.field[1:]
self.omitempty = 'noomitempty' not in self.metadata
def go_declaration(self) -> str:
return self.struct_field_name + ' ' + go_field_type(self.field_type) + f'`json:"{self.field},omitempty"`'
omitempty = ',omitempty' if self.omitempty else ''
return self.struct_field_name + ' ' + go_field_type(self.field_type) + f'`json:"{self.field}{omitempty}"`'
def go_code_for_remote_command(name: str, cmd: RemoteCommand, template: str) -> str:

View File

@@ -13,7 +13,7 @@ class ResizeWindow(RemoteCommand):
protocol_spec = __doc__ = '''
match/str: Which window to resize
self/bool: Boolean indicating whether to resize the window the command is run in
increment/int: Integer specifying the resize increment
increment/int-noomitempty: Integer specifying the resize increment
axis/choices.horizontal.vertical.reset: One of :code:`horizontal, vertical` or :code:`reset`
'''