Skip to content

Commit 0fdf556

Browse files
committed
Tweak timings, fix indent bug.
1 parent 831b363 commit 0fdf556

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

diffcast/diffrunner.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
INITIAL_SPEED = 3
99
TYPING_SPEED = 0.05
10-
INSERT_SPEED = 1.0
10+
INSERT_SPEED = 1.5
1111
DELETE_SPEED = 0.5
1212

1313
DIFF_NO_CHANGE = ' '
@@ -25,9 +25,11 @@ def chunkify(lst, n):
2525
lst = list(lst)
2626
return [lst[i : i + n] for i in range(0, len(lst), n)]
2727

28+
2829
def parse_delta(dc):
2930
return dc[0], dc[2:]
3031

32+
3133
class Signals(QObject):
3234
# emit the row, col and entire text
3335
updated = pyqtSignal(int, int, list)
@@ -104,11 +106,10 @@ def indent_line(self, line, diffline):
104106

105107
def block_indent(self, line, n_lines, dent):
106108
if dent < 0:
107-
self._dedent_line(line, n_lines, abs(dent))
109+
self._dedent_line(line, n_lines, abs(dent))
108110
else:
109111
self._indent_line(line, n_lines, dent)
110112

111-
112113
def edit_line(self, line, diffline):
113114

114115
# diffline has our goal
@@ -193,7 +194,7 @@ def run(self):
193194
delta = self.process_deltas(delta)
194195

195196
cl, dl = 0, 0 # current line, diff line
196-
block_indented = 0 # track indents, so not reapplied
197+
block_indented = 0 # track indents, so not reapplied
197198
while dl < len(delta):
198199

199200
if self._quit_requested:
@@ -214,7 +215,7 @@ def run(self):
214215
if first_char == DIFF_INSERTION and diffline.strip():
215216

216217
tdl = dl
217-
while tdl < len(delta) -1:
218+
while tdl < len(delta) - 1:
218219
tdl += 1
219220
tdc = delta[tdl]
220221
tfc, tdiffline = tdc[0], tdc[2:]
@@ -224,18 +225,18 @@ def run(self):
224225
self.insert_line(cl, tdiffline)
225226
delta[tdl] = (DIFF_NO_CHANGE, None, '')
226227
break
227-
228+
228229
# End temporary lookahead.
229230

230231
# Temporary look-ahead to correctly indent/dedent a block of lines. Does not
231232
# modify the diffs, just the current state. Lines are then re-applied as normal.
232-
if tdl > block_indented and first_char == DIFF_EDIT:
233+
if dl > block_indented and first_char == DIFF_EDIT:
233234
# Calculate the in/dedent.
234235
dent = first_whitespace(diffline) - first_whitespace(self.current[cl])
235236
n_dents = 1
236237
tcl = cl
237238
tdl = dl
238-
while tdl < len(delta) -3:
239+
while tdl < len(delta) - 3:
239240
tdl += 1
240241
tcl += 1
241242

@@ -252,7 +253,7 @@ def run(self):
252253

253254
n_dents += 1
254255

255-
block_indented = tdl # don't apply block indents here again
256+
block_indented = tdl # don't apply block indents here again
256257
if n_dents > 1:
257258
self.block_indent(cl, n_dents, dent)
258259
# End temporary lookahead.

0 commit comments

Comments
 (0)