RESOLVED INVALID 102098
Web Inspector: TextEditor works incorrectly on files having both \r\n and 'n as line breaks.
https://bugs.webkit.org/show_bug.cgi?id=102098
Summary Web Inspector: TextEditor works incorrectly on files having both \r\n and 'n ...
Vsevolod Vlasov
Reported 2012-11-13 09:29:54 PST
Patch to follow
Attachments
WIP (3.19 KB, patch)
2012-11-13 09:31 PST, Vsevolod Vlasov
no flags
Patch (10.79 KB, patch)
2012-11-22 08:29 PST, Vsevolod Vlasov
pfeldman: review+
Vsevolod Vlasov
Comment 1 2012-11-13 09:31:53 PST
Build Bot
Comment 2 2012-11-13 14:43:09 PST
Comment on attachment 173910 [details] WIP Attachment 173910 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/14811974 New failing tests: inspector/editor/text-editor-line-breaks.html inspector/editor/text-editor-model.html
WebKit Review Bot
Comment 3 2012-11-13 23:22:45 PST
Comment on attachment 173910 [details] WIP Attachment 173910 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/14823743 New failing tests: inspector/editor/text-editor-line-breaks.html inspector/editor/text-editor-model.html
Andrey Adaikin
Comment 4 2012-11-13 23:52:31 PST
Comment on attachment 173910 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=173910&action=review > Source/WebCore/ChangeLog:3 > + Web Inspector: TextEditor works incorrectly on files having both \r\n and 'n as line breaks. what does "incorrectly" mean? FYI, i have no clue what you are fixing here. > Source/WebCore/inspector/front-end/TextEditorModel.js:212 > + return line.replace(/\n|\r\n$/, ""); this regex is equivalent to "(\n)|(\r\n$)". did you mean "(\r?\n)+$" ? > Source/WebCore/inspector/front-end/TextEditorModel.js:264 > + var newLines = text.split(/\n/); so, what do you do with \r ? do you assume there will be never a \r in the text? i suggest leaving the existing regex as is. > Source/WebCore/inspector/front-end/TextEditorModel.js:388 > var clip = []; move this line below the if- check.
Vsevolod Vlasov
Comment 5 2012-11-22 08:29:37 PST
Vsevolod Vlasov
Comment 6 2012-11-22 08:37:22 PST
> what does "incorrectly" mean? FYI, i have no clue what you are fixing here. E.g. currently when you open file having both \n and \r\n as a line breaks, following function returns false. function testTextEditorModel() { var text = ...; textModel.setText(text) return textModel.text() === text }
Pavel Feldman
Comment 7 2012-12-14 00:22:11 PST
Comment on attachment 175683 [details] Patch Do you think this is necessary / ready for landing?
Vsevolod Vlasov
Comment 8 2012-12-17 22:31:36 PST
(In reply to comment #7) > (From update of attachment 175683 [details]) > Do you think this is necessary / ready for landing? I think so. Andrey, would you mind looking at it once again?
Andrey Adaikin
Comment 9 2012-12-18 00:41:57 PST
Comment on attachment 175683 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=175683&action=review > Source/WebCore/inspector/front-end/DefaultTextEditor.js:1931 > + */ @return {{line: number, column: number}} > Source/WebCore/inspector/front-end/DefaultTextEditor.js:1960 > + offset += this._textModel.lineLength(i) + 1; // lineBreak this._textModel.lineBreak.length ? > Source/WebCore/inspector/front-end/DefaultTextEditor.js:2252 > + function normalizeLineBreaks(text) not used, remove > Source/WebCore/inspector/front-end/DefaultTextEditor.js:2256 > + console.assert(this._normalizeLineBreaks(this.element.innerText) === this._normalizeLineBreaks(this._textModel.text()) + "\n", "DOM does not match model."); remove? expensive assert > Source/WebCore/inspector/front-end/DefaultTextEditor.js:2260 > + console.assert("No line number on line row"); console.error > Source/WebCore/inspector/front-end/DefaultTextEditor.js:2268 > + console.assert("Chunk is not matching: %d %O", lineNumber, lineRow); console.error > Source/WebCore/inspector/front-end/DefaultTextEditor.js:2270 > + console.assert("Line is not matching: %d %O", lineNumber, lineRow); console.error > Source/WebCore/inspector/front-end/TextEditorModel.js:233 > + if (line.endsWith("\r\n")) charAt?
Note You need to log in before you can comment on or make changes to this bug.