Skip to content

Commit

Permalink
Improve postfix trace (#126)
Browse files Browse the repository at this point in the history
* Improve postfix trace

* Fix other cases

* Fix var/final too with better eating

* minor
  • Loading branch information
RblSb committed Jul 30, 2024
1 parent 1ba3d71 commit 824a48b
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class PostfixCompletion {
label: "trace",
detail: "trace(expr);",
insertText: 'trace($${1:$expr});',
insertTextFormat: Snippet
insertTextFormat: Snippet,
eat: ";"
});
// TODO: check if we're on a sys target
add({
Expand Down Expand Up @@ -348,8 +349,12 @@ while (i-- > 0) {
function createPostfixCompletionItem(data:PostfixCompletionItem, doc:HxTextDocument, removeRange:Range, replaceRange:Range):CompletionItem {
if (data.eat != null) {
final pos = replaceRange.end;
final nextChar = doc.getText({start: pos, end: pos.translate(0, 1)});
if (data.eat == nextChar) {
var nextChar = doc.characterAt(pos);
// if user writes `.l abel` too fast, detect it and check next char again
if (nextChar == data.label.charAt(0) && nextChar != data.eat) {
nextChar = doc.characterAt(pos.translate(0, 1));
}
if (nextChar == data.eat) {
replaceRange = {start: replaceRange.start, end: pos.translate(0, 1)};
}
};
Expand Down

0 comments on commit 824a48b

Please sign in to comment.