Open ParetoOptimalDev opened 10 months ago
Or perhaps this is more useful.
Open a buffer with the name *test-sx-bug*
and then execute:
(with-current-buffer "*test-sx-bug*"
(erase-buffer)
(sx-question-mode--insert-markdown "**\n```\nfoo\n\n```")))
The last invocation of buffer-substring
here doesn't include the ending ``` and I thin that's what causes the regex not to match. It runs against string:
Result: #("** ``` foo" 3 6 (markdown-gfm-block-begin (4 7 4 7 7 7 nil nil nil nil 7 7 #<buffer *test-sx-bug*>) face (markdown-markup-face . #1=(markdown-code-face)) invisible markdown-markup) 6 7 (invisible markdown-markup face #1# font-lock-multiline t) 7 10 (markdown-gfm-code (8 13) font-lock-multiline t face (markdown-pre-face . #1#)))
Inside of sx-question-mode--process-markdown-in-region
function sx-question-mode--dont-fill-here
errors out, specificaly when sx-question-mode--skip-and-fontify-pre gets called on a blank line in:
** ``` foo
\```
Remove the \\
, it's there because I couldn't figure out escaping.
So sx-question-mode--skip-and-fontify-pre
needs to not throw an error maybe? Not sure.
This seems to resolve the issue:
"If there's a pre block ahead, handle it, skip it and return t.
Handling means to turn it into a button and remove erroneous
font-locking.
If DONT-FONTIFY is non-nil, just return the result and possibly
move point, don't create the code-block button."
(let ((beg (line-beginning-position)))
;; To identify code-blocks we need to be at start of line.
(goto-char beg)
(when (fboundp 'markdown-syntax-propertize)
- (markdown-syntax-propertize (point) (point-max)))
+ (ignore-errors
+ (markdown-syntax-propertize (point) (point-max))))
(when (markdown-match-pre-blocks (line-end-position))
(unless dont-fontify
(sx-babel--make-pre-button beg (point)))
t)))
I think it's correct because sx-question-mode--dont-fill-here
expects the functions it calls in a list like sx-question-mode--skip-and-fontify-pre
to not throw errors.
Thanks for the bug report and investigation! This project is definitely in maintenance mode for me – at least for the time being. If you were to open a PR with this change (appropriately formatted with the aggressive-indent
package), I would merge it.
I got nerd sniped into reducing this one for you :smile:
I think it's a markdown issue that might need resolved upstream, of course maybe it's appropriate to just abort highlighting in
sx
when there is an error sincemarkdown-mode
may never be perfect.full backtrace
``` Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) -(nil nil) (save-excursion (goto-char (car prev-begin-block)) (string-match (markdown-maybe-funcall-regexp (car (car correct-entry))) (buffer-substring (line-beginning-position) (line-end-position))) (- (match-end 1) (match-beginning 1))) (let* ((correct-entry (cl-find-if #'(lambda (entry) (eq (cdr prev-begin-block) (car ...))) markdown-fenced-block-pairs)) (enclosed-text-start (1+ (car prev-begin-block))) (start-length (save-excursion (goto-char (car prev-begin-block)) (string-match (markdown-maybe-funcall-regexp (car (car correct-entry))) (buffer-substring (line-beginning-position) (line-end-position))) (- (match-end 1) (match-beginning 1)))) (end-reg (markdown-maybe-funcall-regexp (car (car (cdr correct-entry))) start-length))) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start)) (progn (let* ((correct-entry (cl-find-if #'(lambda (entry) (eq ... ...)) markdown-fenced-block-pairs)) (enclosed-text-start (1+ (car prev-begin-block))) (start-length (save-excursion (goto-char (car prev-begin-block)) (string-match (markdown-maybe-funcall-regexp (car ...)) (buffer-substring (line-beginning-position) (line-end-position))) (- (match-end 1) (match-beginning 1)))) (end-reg (markdown-maybe-funcall-regexp (car (car (cdr correct-entry))) start-length))) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start))) (if prev-begin-block (progn (let* ((correct-entry (cl-find-if #'(lambda ... ...) markdown-fenced-block-pairs)) (enclosed-text-start (1+ (car prev-begin-block))) (start-length (save-excursion (goto-char (car prev-begin-block)) (string-match (markdown-maybe-funcall-regexp ...) (buffer-substring ... ...)) (- (match-end 1) (match-beginning 1)))) (end-reg (markdown-maybe-funcall-regexp (car (car ...)) start-length))) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start)))) (let ((prev-begin-block (markdown-find-previous-block))) (if prev-begin-block (progn (let* ((correct-entry (cl-find-if #'... markdown-fenced-block-pairs)) (enclosed-text-start (1+ (car prev-begin-block))) (start-length (save-excursion (goto-char ...) (string-match ... ...) (- ... ...))) (end-reg (markdown-maybe-funcall-regexp (car ...) start-length))) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start))))) (save-excursion (goto-char start) (let ((prev-begin-block (markdown-find-previous-block))) (if prev-begin-block (progn (let* ((correct-entry (cl-find-if ... markdown-fenced-block-pairs)) (enclosed-text-start (1+ ...)) (start-length (save-excursion ... ... ...)) (end-reg (markdown-maybe-funcall-regexp ... start-length))) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start))))) (while (re-search-forward start-reg end t) (let* ((block-start (match-beginning 0)) (cur-line (buffer-substring (line-beginning-position) (line-end-position))) (correct-entry (cl-find-if #'(lambda ... ...) markdown-fenced-block-pairs)) (enclosed-text-start (save-excursion (1+ (line-end-position)))) (end-reg (markdown-maybe-funcall-regexp (car (car ...)) (if (and ... ...) (- ... ...) 0))) (prop (car (cdr (car correct-entry))))) (if (or (not (eq prop 'markdown-gfm-block-begin)) (not (markdown--triple-quote-single-line-p block-start))) (progn (save-excursion (beginning-of-line) (re-search-forward (markdown-maybe-funcall-regexp ...) (line-end-position))) (put-text-property (match-beginning 0) (match-end 0) prop (match-data t)) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start)))))) (let ((start-reg (markdown-get-start-fence-regexp))) (save-excursion (goto-char start) (let ((prev-begin-block (markdown-find-previous-block))) (if prev-begin-block (progn (let* ((correct-entry ...) (enclosed-text-start ...) (start-length ...) (end-reg ...)) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start))))) (while (re-search-forward start-reg end t) (let* ((block-start (match-beginning 0)) (cur-line (buffer-substring (line-beginning-position) (line-end-position))) (correct-entry (cl-find-if #'... markdown-fenced-block-pairs)) (enclosed-text-start (save-excursion (1+ ...))) (end-reg (markdown-maybe-funcall-regexp (car ...) (if ... ... 0))) (prop (car (cdr ...)))) (if (or (not (eq prop ...)) (not (markdown--triple-quote-single-line-p block-start))) (progn (save-excursion (beginning-of-line) (re-search-forward ... ...)) (put-text-property (match-beginning 0) (match-end 0) prop (match-data t)) (markdown-propertize-end-match end-reg end correct-entry enclosed-text-start))))))) markdown-syntax-propertize-fenced-block-constructs(3145 5256) (save-excursion (remove-text-properties start end markdown--syntax-properties) (markdown-syntax-propertize-fenced-block-constructs start end) (markdown-syntax-propertize-list-items start end) (markdown-syntax-propertize-pre-blocks start end) (markdown-syntax-propertize-blockquotes start end) (markdown-syntax-propertize-headings start end) (markdown-syntax-propertize-hrs start end) (markdown-syntax-propertize-comments start end)) (progn (save-excursion (remove-text-properties start end markdown--syntax-properties) (markdown-syntax-propertize-fenced-block-constructs start end) (markdown-syntax-propertize-list-items start end) (markdown-syntax-propertize-pre-blocks start end) (markdown-syntax-propertize-blockquotes start end) (markdown-syntax-propertize-headings start end) (markdown-syntax-propertize-hrs start end) (markdown-syntax-propertize-comments start end))) (unwind-protect (progn (save-excursion (remove-text-properties start end markdown--syntax-properties) (markdown-syntax-propertize-fenced-block-constructs start end) (markdown-syntax-propertize-list-items start end) (markdown-syntax-propertize-pre-blocks start end) (markdown-syntax-propertize-blockquotes start end) (markdown-syntax-propertize-headings start end) (markdown-syntax-propertize-hrs start end) (markdown-syntax-propertize-comments start end))) (if (or (not modified) (eq modified 'autosaved)) (progn (restore-buffer-modified-p modified)))) (let* ((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-modification-hooks t)) (unwind-protect (progn (save-excursion (remove-text-properties start end markdown--syntax-properties) (markdown-syntax-propertize-fenced-block-constructs start end) (markdown-syntax-propertize-list-items start end) (markdown-syntax-propertize-pre-blocks start end) (markdown-syntax-propertize-blockquotes start end) (markdown-syntax-propertize-headings start end) (markdown-syntax-propertize-hrs start end) (markdown-syntax-propertize-comments start end))) (if (or (not modified) (eq modified 'autosaved)) (progn (restore-buffer-modified-p modified))))) markdown-syntax-propertize(3145 5256) sx-question-mode--skip-and-fontify-pre() sx-question-mode--dont-fill-here() sx-question-mode--process-markdown-in-region(254 6555) sx-question-mode--insert-markdown("I know this will probably be a bit of a repeat but none of the several topics I have browsed and tried have worked out fully for me. I will try to give as much (necessary) info as I can, if there is unrelated info or info that is needed please tell me what and how I can retrieve it and I'll do my best. Sorry it's long I just wanna be thorough with my question and info.\n\nThank you for taking your time to read this.\n\n### Main Issue ###\n\nI am trying to hide the fact that it's a VM from my guest, mainly because I want to play some games that do not play well with their anti-cheat being on a VM, for example Valorant. I have tried many guides online but none seem to work. While windows thinks it's running on outside a virtual machine, Checking in PAFish these are the traces I get.\n\n### PAFish Traces ###\n [-] CPU information based detections\n [*] Checking the difference between CPU timestamp counters (rdtsc) forcing VM exit ... traced!\n [*] Checking hypervisor bit in cpuid feature bits ... traced! \n [*] Checking cpuid hypervisor vendor for known VM vendors ... traced! \n\n [-] Generic sandbox detection \n [*] Using mouse activity ... traced! \n [*] Checking operating system uptime using GetTickCount() ... traced!\n\n [-] Qemu detection\n [*] Scsi port->bus->target id->logical unit id-> 0 identifier ... traced!\n\n [-] Bochs detection\n [*] Reg key (HKLM\\HARDWARE\\Description\\System \"SystemBiosVersion\") ... traced!\n\nAnd I want to try to fix/mitigate them. Now I realize that Valorant AC might use some other ways as well but I figure this is a good place to start. \n\nBelow will be a bit of an infodump of what I have done attempting this.\n\n**My cpu, motherboard and OS are:**\n\n OS: Manjaro Linux x86_64\n Host: MS-7C37 2.0\n CPU: AMD Ryzen 7 3800X (16) @ 3.900GHz\n\n*I have enabled nested virtualization for my AMD CPU*\n\nI am running qemu under virt-manager with windows 10 Pro 64bit as a guest. [Here](https://pastebin.com/0y0MTWiG \"KVM XML Pastebin\") is a pastebin of my xml file for my VM but I will include what I think are the relevant parts for each trace in each section.\n\n\n### SystemBiosVersion ###\n**The more important (I think) parts are that I have changed the bios vendor etc:**\n\nI started with:
Then after seeing arguments and what the results of this were:
Reduced the size of the reproducer quite a lot by trial and error: