Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f981173e6b09fa1c7c325c4184bec3be77c667fb
https://github.com/WebKit/WebKit/commit/f981173e6b09fa1c7c325c4184bec3be77c667fb
Author: Razvan Caliman <[email protected]>
Date: 2025-11-20 (Thu, 20 Nov 2025)
Changed paths:
M Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
Log Message:
-----------
Web Inspector: Breakpoints are misplaced and search results highlight the
wrong location
https://bugs.webkit.org/show_bug.cgi?id=302798
rdar://165059693
Reviewed by Devin Rousso.
It is possible to get into a state where a previously formatted (aka
pretty-printed) file is rendered again not formatted,
but all source code locations for breakpoints and search results still use the
formatted line locations.
There's no strict dependency between the formatted state of a `WI.SourceCode`
and an associated view like `WI.SourceCodeTextEditor`.
The view can get destroyed and re-created as needed, for example in repeated
queries in Web Inspector search.
See `WI.ContentViewContainer.prototype.closeAllContentViews()` called by
`WI.SearchSidebarPanel.prototype.performSearch()`
When a `WI.SourceCodeLocation` is created, its formatted line / column start
off identical to the original line / number.
See `WI.SourceCodeLocation.prototype._resolveFormattedLocation()`.
When `WI.SourceCode` is pretty-printed, the formatted line / column get updated
according to
`WI.SourceCode.prototype.formatterSourceMap`. All previous and future
breakpoints and source code locations are resolved against it.
`WI.SourceCode` remembers its formatted source map. But its source code editor
view might not, for example
when the editor is re-created but its content is not automatically formatted
because it fails the necessary conditions.
A re-created editor view (`WI.SourceCodeTextEditor`) and its backing model
(`WI.SourceCode`) can get out of sync.
Since breakpoints and search result locations are always resolved against the
model and accessed intentionally with
`WI.SourceCodeLocation.prototype.formattedPosition()` (because of the
assumption this will point to original locations if unformatted),
existing and new source code locations point to the wrong location the new
unformatted editor view.
This patch forces the editor view to automatically format its content if its
backing model was previously formatted.
* Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor):
Canonical link: https://commits.webkit.org/303327@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications