MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / cleanLine

Function cleanLine

src/lineCache.ts:49–68  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

47}
48
49export function cleanLine(text: string): string {
50 let cleaned = '';
51 let withinQuotes = null;
52 for (let i = 0; i < text.length; i++) {
53 const c = text[i];
54 if (isQuote(c)) {
55 if (withinQuotes === null) {
56 withinQuotes = c;
57 } else if (withinQuotes === c) {
58 withinQuotes = null;
59 }
60 }
61 if (isComment(c) && !withinQuotes) {
62 break;
63 }
64
65 cleaned += c;
66 }
67 return (cleaned.trimEnd());
68}
69
70function doesLineEndInOperator(text: string) {
71 const endingOperatorIndex = text.search(/(\(|,|\+|!|\$|\^|&|\*|-|=|:|~|\||\/|\?|<|>|%.*%)(\s*|\s*#.*)$/);

Callers 3

lineCache.test.tsFile · 0.90
addLineToCacheMethod · 0.85

Calls 2

isCommentFunction · 0.85
isQuoteFunction · 0.70

Tested by

no test coverage detected