Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line wrapping breaks custom multiline problem matchers #85839

Closed
enizor opened this issue Nov 29, 2019 · 14 comments
Closed

Line wrapping breaks custom multiline problem matchers #85839

enizor opened this issue Nov 29, 2019 · 14 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug tasks Task system issues windows VS Code on Windows issues wont-fix
Milestone

Comments

@enizor
Copy link

enizor commented Nov 29, 2019

Related to #32042 & #45107

  • VSCode Version: 1.40.2 & 1.41.0-insiders
  • OS Version: Windows 1803 (conpty unavailable)

Steps to Reproduce:

  1. Create a task outputting multiple long lines that will get wrapped in the terminal
  2. Use a custom multiline pattern that should match on a part split into the two lines
  3. Run the task with a limietd space for the terminal (so that the terminal will wrap lines) and having it opened beforehand (to avoid Wrapped task output if Terminal not opened #81328)
  4. Observe the matched problems

Observation:
Pattern tries to match only on the first part of a wrapped line

Exemple:

"pattern": [
    {
        "kind": "file",
        "regexp": "^## \\+\\+ (WARNING|ERROR) : \\S+ : (.*)",
        "severity": 1,
        "message": 2,
    },
    {
        "kind": "file",
        "regexp": "^## \\+\\+ WARNING|ERROR : see Output file in (\\S+)",
        "file": 1
    }
]

Wrapped output:

## ++ ERROR : test_name : error message
## ++ ERROR : see Output file in c:\a\very\long\absolute\path\to\somewhere\in\the\wo
rkspace\test.traces

Resulting error:
error message is parsed correctly but the file location is parsed as c:\a\very\long\absolute\path\to\somewhere\in\the\wo

Does this issue occur when all extensions are disabled?: Yes

EDIT: The wrapped-line parsing works correctly if a single regexp is used.

@vscodebot vscodebot bot added the tasks Task system issues label Nov 29, 2019
@alexr00 alexr00 added the bug Issue identified by VS Code Team member as probable bug label Dec 2, 2019
@alexr00 alexr00 added this to the December 2019 milestone Dec 2, 2019
@alexr00
Copy link
Member

alexr00 commented Dec 10, 2019

I think there's nothing we can do about this for winpty. The terminal sees that as three lines.
For conpty, I'm seeing this come through as 3 lines as well:

termline: "## ++ ERROR : test_name : error message"
termline: "## ++ ERROR : see Output file in c:\a\very\long\absolute\path\to
termline: "## ++ ERROR : see Output file in c:\a\very\long\absolute\path\to\somewhere\in\the\workspace\test.traces"

@Tyriar to confirm.

@Tyriar
Copy link
Member

Tyriar commented Dec 30, 2019

Hacks on hacks! I guess we could suppress triggering the end of a line here:

// Force line data to be sent when the cursor is moved, the main purpose for
// this is because ConPTY will often not do a line feed but instead move the
// cursor, in which case we still want to send the current line's data to tasks.
xterm.parser.addCsiHandler({ final: 'H' }, () => {
this._onCursorMove();
return false;
});

By using the same end of line wrapping trick:

if (newLine && !newLine.isWrapped) {
this._sendLineData(buffer, buffer.baseY + buffer.cursorY - 1);
}

@Tyriar
Copy link
Member

Tyriar commented Dec 30, 2019

@alexr00 could you try add this to conditional to _onCursorMove to see if it fixes since you can repro this easier than me?

const buffer = this._xterm!.buffer;
const newLine = buffer.getLine(buffer.baseY + buffer.cursorY);
if (newLine && !newLine.isWrapped) {

@alexr00
Copy link
Member

alexr00 commented Jan 6, 2020

Updated _onCursorMove:

	private _onCursorMove(): void {
		const buffer = this._xterm!.buffer;
		const newLine = buffer.getLine(buffer.baseY + buffer.cursorY);
		if (newLine && !newLine.isWrapped) {
			this._sendLineData(buffer, buffer.baseY + buffer.cursorY);
		}
	}

But I still see the extra broken line.

@Tyriar
Copy link
Member

Tyriar commented Jan 6, 2020

@alexr00 hmm, the fix might be a little more involved thinking about this more as linefeed hasn't fired at this point. We probably need to change this in xterm.js' window's mode to also run when the cursor is moved:

https://github.com/xtermjs/xterm.js/blob/70babeacb62fe05264d64324ca1f4436997efa1b/src/common/WindowsMode.ts#L9-L26

Does this work just to test out the theory? Below will treat all lines > 10 chars in width as wrapped (and not send line data).

	private _onCursorMove(): void {
		const buffer = this._xterm!.buffer;
		const newLine = buffer.getLine(buffer.baseY + buffer.cursorY);
		// Only send the line when the cursor is < 10
		if (newLine && buffer.cursorX < 10) {
			this._sendLineData(buffer, buffer.baseY + buffer.cursorY);
		}
	}

@alexr00
Copy link
Member

alexr00 commented Jan 7, 2020

@Tyriar that does solve this problem. I now just get the expected two lines and no broken lines.

Tyriar added a commit that referenced this issue Jan 7, 2020
Diff: xtermjs/xterm.js@2a9e16b...fbeb45d

- Adding FluffOS to xtermjs user list xtermjs/xterm.js#2663
- Flag lines as wrapped after CUP in windows mode xtermjs/xterm.js#2667

Part of #85839
@Tyriar
Copy link
Member

Tyriar commented Jan 7, 2020

@alexr00 I pulled in the change from xtermjs/xterm.js#2666, can you try it out and see if it's fixed now? (make sure you run yarn to pull in the new xterm version)

@alexr00
Copy link
Member

alexr00 commented Jan 8, 2020

Pulled and yarned, but I'm still seeing the extra broken line in onLineData:

termline: "## ++ ERROR : test_name : error message"
termline: "## ++ ERROR : see Output file in c:\a\very\long\absolute\path\to\somewhere\in\the\worksp
termline: "## ++ ERROR : see Output file in c:\a\very\long\absolute\path\to\somewhere\in\the\workspace\test.traces"

@Tyriar
Copy link
Member

Tyriar commented Jan 13, 2020

Might be related to the order of CSI handlers

@dsanders11
Copy link
Member

@alexr00 @Tyriar, is there any hope of progress on this?

It affects the text captured by a problem matcher in weird ways, you don't even need long lines. If your window is small, it will be messed up by the wrapping of the terminal output. However, that only happens if you're viewing the terminal output. If I run a task and let it run without viewing the terminal output, the problem matcher works as expected. If I run the same task but view the terminal output while it runs, the visual wrapping done due to the small window affects the captured output by problem matchers.

It seems like that's a hint in the right direction here? Can the problem matchers be run on the raw output, like when the user hasn't viewed the terminal? That way wrapping in the terminal wouldn't affect anything.

@Tyriar
Copy link
Member

Tyriar commented Nov 11, 2020

There is hope as proper text wrapping support was added to conpty: #91898

@dsanders11
Copy link
Member

@Tyriar, thanks for the info. I see that issue is from March, any vague idea on timeline of when it all might land? First half of 2021?

@Tyriar
Copy link
Member

Tyriar commented Nov 12, 2020

@dsanders11 the linked issue says the build after 19041 which is end of 2020, start of 20221. It's not clear yet if we need to do something to adopt it (like removing our heuristics if it works).

@Tyriar
Copy link
Member

Tyriar commented Oct 11, 2021

Closing this off as we don't plan on improving the winpty support and the issue isn't about conpty.

@Tyriar Tyriar closed this as completed Oct 11, 2021
@Tyriar Tyriar added windows VS Code on Windows issues wont-fix labels Oct 11, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug tasks Task system issues windows VS Code on Windows issues wont-fix
Projects
None yet
Development

No branches or pull requests

4 participants