File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
src/Haskell/Ide/Engine/Transport Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -295,11 +295,58 @@ updatePositionMap uri changes = pluginGetFile "updatePositionMap: " uri $ \file
295
295
return $ IdeResultOk ()
296
296
where
297
297
f (+/-) (J. Range (Position sl sc) (Position el ec)) txt p@ (Position l c)
298
+
299
+ -- pos is before the change - unaffected
298
300
| l < sl = Just p
301
+ -- pos is somewhere after the changed line,
302
+ -- move down the pos to keep it the same
299
303
| l > el = Just $ Position l' c
304
+
305
+ {-
306
+ LEGEND:
307
+ 0-9 char index
308
+ x untouched char
309
+ I/i inserted/replaced char
310
+ . deleted char
311
+ ^ pos to be converted
312
+ -}
313
+
314
+ {-
315
+ 012345 67
316
+ xxxxxx xx
317
+ ^
318
+ 0123456789
319
+ xxIIIIiixx
320
+ ^
321
+
322
+ pos is unchanged if before the edited range
323
+ -}
300
324
| l == sl && c <= sc = Just p
325
+
326
+ {-
327
+ 01234 56
328
+ xxxxx xx
329
+ ^
330
+ 012345678
331
+ xxIIIiixx
332
+ ^
333
+ If pos is in the affected range move to after the range
334
+ -}
301
335
| l == sl && l == el && c <= nec && newL == 0 = Just $ Position l ec
336
+
337
+ {-
338
+ 01234 56
339
+ xxxxx xx
340
+ ^
341
+ 012345678
342
+ xxIIIiixx
343
+ ^
344
+ If pos is after the affected range, update the char index
345
+ to keep it in the same place
346
+ -}
302
347
| l == sl && l == el && c > nec && newL == 0 = Just $ Position l (c +/- (nec - sc))
348
+
349
+ -- oh well we tried ¯\_(ツ)_/¯
303
350
| otherwise = Nothing
304
351
where l' = l +/- dl
305
352
dl = newL - oldL
You can’t perform that action at this time.
0 commit comments