persona-community-5/.pnpm-store/v3/files/b0/c4128473037fe02001b60bd37d4bfe60822828e92757c4e53e380dc6a554adeb7a76ac9e84efcd4c23c33bf691b40aa3a549d0486e23dcc42eeabbab9f8494
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

77 lines
1.5 KiB
Plaintext

'use strict';
import common = require('./common');
class Mark{
constructor(public name:string, public buffer:string, public position:number, public line:number, public column:number) {
}
filePath: string;
toLineEnd:boolean;
getSnippet(indent:number=0, maxLength:number=75) {
var head, start, tail, end, snippet;
if (!this.buffer) {
return null;
}
indent = indent || 4;
maxLength = maxLength || 75;
head = '';
start = this.position;
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
start -= 1;
if (this.position - start > (maxLength / 2 - 1)) {
head = ' ... ';
start += 5;
break;
}
}
tail = '';
end = this.position;
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
end += 1;
if (end - this.position > (maxLength / 2 - 1)) {
tail = ' ... ';
end -= 5;
break;
}
}
snippet = this.buffer.slice(start, end);
return common.repeat(' ', indent) + head + snippet + tail + '\n' +
common.repeat(' ', indent + this.position - start + head.length) + '^';
}
toString (compact:boolean=true) {
var snippet, where = '';
if (this.name) {
where += 'in "' + this.name + '" ';
}
where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
if (!compact) {
snippet = this.getSnippet();
if (snippet) {
where += ':\n' + snippet;
}
}
return where;
}
}
export = Mark