Skip to content

Commit

Permalink
[sheet-] both names and name setter will set both _names and _name
Browse files Browse the repository at this point in the history
  • Loading branch information
anjakefala committed May 17, 2024
1 parent 43347b6 commit ef6c6a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions visidata/basesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def _class_options(cls):

def __init__(self, *names, rows=UNLOADED, **kwargs):
self._name = None # initial cache value necessary for self.options
self._names = []
self.loading = False
self.names = list(names)
self.name = self.options.name_joiner.join(str(x) for x in self.names if x)
self.source = None
self.rows = rows # list of opaque objects
self._scr = None
Expand Down Expand Up @@ -238,8 +238,10 @@ def names(self):

@names.setter
def names(self, names):
if self._names:
vd.addUndo(setattr, self, 'names', self._names)
self._names = names
self.name = self.options.name_joiner.join(self.maybeClean(str(x)) for x in self._names)
self._name = self.options.name_joiner.join(self.maybeClean(str(x)) for x in self._names)

@property
def name(self):
Expand All @@ -250,9 +252,9 @@ def name(self):
def name(self, name):
'Set name without spaces.'
if self._names:
vd.addUndo(setattr, self, '_names', self._names)
vd.addUndo(setattr, self, 'names', self._names)
self._name = self.maybeClean(str(name))
self._names = self._name.split(self.options.name_joiner)
self._names = [self._name]

def maybeClean(self, s):
'stub'
Expand Down

0 comments on commit ef6c6a2

Please sign in to comment.