Skip to content

Fix label creation position - #11872

Merged
grliszas14 merged 1 commit into
audacity:masterfrom
RiccardoCampo:fix-new-label-position
Sep 9, 2026
Merged

grliszas14 merged 1 commit into
audacity:masterfrom
RiccardoCampo:fix-new-label-position

Conversation

@RiccardoCampo

Copy link
Copy Markdown
Contributor

Resolves: #11682

When the track selection is a point, create a label at the playback position. Before this change, the label was created at the selection position, which may be ambiguous since you cannot see the point selection.

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 13c9124c-19ee-4b97-b23d-0a100cacf910

📥 Commits

Reviewing files that changed from the base of the PR and between 4ca26aed68a0a8d23d30c0dfa0459eb354387bde and 883f90e.

📒 Files selected for processing (2)
  • src/trackedit/internal/au3/au3labelsinteraction.cpp
  • src/trackedit/tests/au3labelsinteractions_tests.cpp

📝 Walkthrough

Walkthrough

addLabelToSelection now creates a point label at the current playback position when the selection is empty. Non-empty selections retain their start and end times. The method now returns the created LabelKey. The focused test configures playback at 3.5 seconds and verifies both point-label boundaries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 4ca26

Point labels created from an empty selection now appear at the playback position, while range labels retain their selected bounds. The behavior is covered by an updated focused test, with no remaining merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: correcting the position used when creating labels.
Description check ✅ Passed The description identifies issue #11682, explains the behavior change and motivation, and completes the relevant checklist items. The unchecked testflow item is non-critical, and the unchecked extensi…
Linked Issues check ✅ Passed The implementation handles zero-length selections by creating a point label at the playback position, and the test verifies this behavior. This addresses the label-placement problem described in issue…
Out of Scope Changes check ✅ Passed The changes are limited to label creation behavior and its corresponding test. No unrelated code or behavior changes are present.

Warning

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

selectionController()->dataSelectedEndTime());
const double selectionStart = selectionController()->dataSelectedStartTime();
const double selectionEnd = selectionController()->dataSelectedEndTime();
if (selectionEnd > selectionStart) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use RealIsEqualOrLess for "double" comparisons
if (!muse::RealIsEqualOrLess(selectionEnd, selectionStart)
or (I prefer this)
selectionController()->timeSelectionIsEmpty() where we already use RealIsEqualOrLess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end I had to use muse::RealIsEqualOrLess(selectionEnd, selectionStart) as dataSelectedStartTime() returns a different value (m_selectedStartTime.changed) wrt what is used in timeSelectionIsEmpty (m_selectedStartTime.val)

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@grliszas14
grliszas14 force-pushed the fix-new-label-position branch from 4ca26ae to 883f90e Compare September 9, 2026 12:17
@grliszas14
grliszas14 merged commit f6d5b0b into audacity:master Sep 9, 2026
@grliszas14

Copy link
Copy Markdown
Contributor

@RiccardoCampo thanks for the contribution! merged

@RiccardoCampo
RiccardoCampo deleted the fix-new-label-position branch September 19, 2026 07:09
kryksyh added a commit that referenced this pull request Sep 22, 2026
Fix label creation position (#11872)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Label is created at a wrong position

3 participants