Skip to content

Commit

Permalink
Handles symbol boundaries. Problem much more evident in Emacs and oth…
Browse files Browse the repository at this point in the history
…er cursor based editors. For #57
  • Loading branch information
bscan committed Dec 29, 2022
1 parent a18cdee commit b302fc7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export function getSymbol(position: Position, txtDoc: TextDocument) {
let left = index - 1;
let right = index;

if(right < text.length && ( ["$", "%", "@"].includes(text[right]) || rightAllow(text[right])) ){
// Handles an edge case where the cursor is on the side of a symbol.
// Note that $foo| should find $foo (where | represents cursor), but $foo|$bar should find $bar, and |mysub should find mysub
right += 1;
left += 1;
}

while (left >= 0 && leftAllow(text[left])) {
// Fat comma check
if (text[left] === ">" && left - 1 >= 0 && text[left - 1] === "=") { break; }
Expand Down

0 comments on commit b302fc7

Please sign in to comment.