Sunday, October 2, 2016

Re: Slow Python syntax highlighting

# --== Month ==--

if mArgs.action == 'month':

# Set the target day to any day that the target month contains
if mArgs.month is None:
TARGET_DAY = date.Date()

elif re.fullmatch('\d+/\d+/\d+', mArgs.month) is not None or re.fullmatch('\d+/\d+', mArgs.month) is not None:
TARGET_DAY = date.makeFromString(mArgs.month)

else:
month = months.makeFromName(mArgs.month)

if month == months.ERROR_INVALID_MONTH_NAME:
print('%s is not a valid month name, please see help' % mArgs.month)
sys.exit()

if month == months.ERROR_AMBIGUOUS_MONTH_NAME:
print('%s is an ambiguous month name' % mArgs.month)
sys.exit()

TARGET_DAY = date.makeFromString('01/%02u' % month)

# Report
tab = table.Table(options = {'rowSpacing': 0, 'alignments': [table.ALIGN_LEFT, table.ALIGN_RIGHT, table.ALIGN_RIGHT]})
totalDue = 0
totalLoad = 0

tab.appendToHeader(['', 'Work hours', 'Overtime'])

for day in [day for day in TARGET_DAY.makeMonthDays() if day <= TODAY]:

if day not in timeclock:
if day.isWorkDay(): timeclock[day] = {'load': 0, 'tasks': [], 'overtime': 0}
else: continue

if day.getWeekDay() == 0:
tab.appendSeparator()

tab.append([
{'type': table.TYPE_STRING, 'value': '%s %s' % (day.getWeekDayAsShortString(), day) },
{'type': table.TYPE_MINUTES, 'value': timeclock[day]['load'] },
{'type': table.TYPE_MINUTES_DIFFERENCE, 'value': timeclock[day]['load'] - DUE_LOAD_PER_DAY if day.isWorkDay() else 0},
])

totalDue += DUE_LOAD_PER_DAY if day.isWorkDay() else 0
totalLoad += timeclock[day]['load']

tab.appendToFooter([
{'type': table.TYPE_STRING, 'value': '' },
{'type': table.TYPE_MINUTES, 'value': totalLoad },
{'type': table.TYPE_MINUTES_DIFFERENCE, 'value': totalLoad - totalDue},
])

print(tab)

# --== Year ==--

if mArgs.action == 'year':

# Set the target day to any day that the target year contains
if mArgs.year is None: TARGET_DAY = date.Date()
else: TARGET_DAY = date.makeFromString('01/01/%04u' % mArgs.year)

# Compute actual and due load per month
year = [{'due': 0, 'actual': 0, 'manualOT': 0} for i in range(13)]

for day in [day for day in TARGET_DAY.makeYearDays() if day <= TODAY]:

if day.isWorkDay():
year[day.getMonth()]['due'] += DUE_LOAD_PER_DAY

if day in timeclock:
year[day.getMonth()]['actual'] += timeclock[day]['load']
year[day.getMonth()]['manualOT'] += timeclock[day]['overtime']

# Report
tab = table.Table(options = {'alignments': [table.ALIGN_LEFT, table.ALIGN_RIGHT, table.ALIGN_RIGHT, table.ALIGN_RIGHT]})

tab.appendToHeader(['', 'Work hours', 'Overtime', 'Adjustment'])

for monthIdx, day in enumerate([day for day in TARGET_DAY.makeFirstMonthDays() if day <= TODAY]):
tab.append([
{'type': table.TYPE_STRING, 'value': day.getMonthName() }, # Month
{'type': table.TYPE_MINUTES, 'value': year[day.getMonth()]['actual'] }, # Work hours
{'type': table.TYPE_MINUTES_DIFFERENCE, 'value': year[day.getMonth()]['actual'] - year[day.getMonth()]['due']}, # Overtime (can be negative as well)
{'type': table.TYPE_MINUTES_DIFFERENCE, 'value': year[day.getMonth()]['manualOT'] }, # Manual adjustment to overtime
])

tab.appendToFooter([
{'type': table.TYPE_STRING, 'value': '' },
{'type': table.TYPE_MINUTES, 'value': sum([month['actual'] for month in year]) },
{'type': table.TYPE_MINUTES_DIFFERENCE, 'value': sum([month['actual'] for month in year]) - sum([month['due'] for month in year]) + sum([month['manualOT'] for month in year])},
{'type': table.TYPE_STRING, 'value': '' },
])

print(tab)
Hi Dominique,

On 1 October 2016 at 09:46, Dominique Pellé wrote:
> Can you provide a file where it happens and a minimalistic
> vimrc, just enough to reproduce it?

Here's what I came up with.

If I type o to open a new line:
- On line 87, it's instantaneous
- On line 85, there's a noticeable lag

With :syntax off, it's instantaneous in both cases. It may have
something to do with indent as well, because turning off indent in the
.vimrc solves the issue as well.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment