Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed silly code. #87

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/replace.ls
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ replace = (replacement, input, nodes, query-engine) ->
end-line-num = end.line - 1 + line-offset
number-of-lines = end-line-num - start-line-num + 1

col-offset := if last-line is start-line-num then col-offset else 0
col-offset := if "id" of prev-node and prev-node.loc.end.line!=start.line then col-offset else 0

start-col = start.column + col-offset
end-col = end.column + if start-line-num is end-line-num then col-offset else 0
Expand All @@ -190,8 +190,8 @@ replace = (replacement, input, nodes, query-engine) ->
input-lines.splice start-line-num, number-of-lines, ...replace-lines

line-offset += replace-lines.length - number-of-lines
col-offset += end-len - end-col
last-line := end-line-num + line-offset
col-offset = (if start-line-num != end-line-num and replace-lines.length == 1 then 0 else col-offset) + end-len - end-col
last-line := end-line-num
prev-node := node

unlines input-lines
Expand Down